1 | $|=1; |
|
|
2 | $^W=0; |
|
|
3 | |
|
|
4 | BEGIN { |
1 | BEGIN { |
5 | # check for broken perls |
2 | # check for broken perls |
6 | if ($^O =~ /mswin32/i) { |
3 | if ($^O =~ /mswin32/i) { |
7 | my $ok; |
4 | my $ok; |
8 | local $SIG{CHLD} = sub { $ok = 1 }; |
5 | local $SIG{CHLD} = sub { $ok = 1 }; |
… | |
… | |
16 | } |
13 | } |
17 | } |
14 | } |
18 | } |
15 | } |
19 | |
16 | |
20 | BEGIN { |
17 | BEGIN { |
|
|
18 | $|=1; |
21 | print "1..7\n" |
19 | print "1..7\n" |
22 | } |
20 | } |
23 | |
21 | |
|
|
22 | use POSIX (); |
|
|
23 | |
24 | use AnyEvent; |
24 | use AnyEvent; |
25 | use AnyEvent::Impl::POE; |
25 | use AnyEvent::Impl::POE; $^W = 0; |
|
|
26 | |
|
|
27 | $AnyEvent::MAX_SIGNAL_LATENCY = 1; |
26 | |
28 | |
27 | print "ok 1\n"; |
29 | print "ok 1\n"; |
28 | |
30 | |
29 | AnyEvent::detect; # force-load event model |
31 | AnyEvent::detect; # force-load event model |
30 | |
32 | |
… | |
… | |
37 | |
39 | |
38 | my $cv = AnyEvent->condvar; |
40 | my $cv = AnyEvent->condvar; |
39 | |
41 | |
40 | unless ($pid) { |
42 | unless ($pid) { |
41 | print "ok 2\n"; |
43 | print "ok 2\n"; |
42 | exit 3; |
44 | POSIX::_exit 3; |
43 | } |
45 | } |
44 | |
46 | |
45 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
47 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
46 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
48 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
47 | print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; |
49 | print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; |
48 | $cv->broadcast; |
50 | $cv->broadcast; |
49 | }); |
51 | }); |
50 | |
52 | |
51 | $cv->wait; |
53 | $cv->wait; |
52 | |
54 | |
53 | my $pid2 = fork || exit 7; |
55 | my $pid2 = fork || POSIX::_exit 7; |
54 | |
56 | |
55 | my $cv2 = AnyEvent->condvar; |
57 | my $cv2 = AnyEvent->condvar; |
56 | |
58 | |
57 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
59 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
58 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |
60 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |
59 | print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; |
61 | print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; |
60 | $cv2->broadcast; |
62 | $cv2->broadcast; |
61 | }); |
63 | }); |
62 | |
64 | |
63 | my $error = AnyEvent->timer (after => 5, cb => sub { |
65 | my $error = AnyEvent->timer (after => 15, cb => sub { |
64 | print <<EOF; |
66 | print <<EOF; |
65 | Bail out! No child exit detected. This is either a bug in AnyEvent or a bug in your Perl (mostly some windows distributions suffer from that): child watchers might not work properly on this platform. You can force installation of this module if you do not rely on child watchers, or you could upgrade to a working version of Perl for your platform.\n"; |
67 | Bail out! No child exit detected. This is either a bug in AnyEvent or a bug in your Perl (mostly some windows distributions suffer from that): child watchers might not work properly on this platform. You can force installation of this module if you do not rely on child watchers, or you could upgrade to a working version of Perl for your platform.\n"; |
66 | EOF |
68 | EOF |
67 | exit 0; |
69 | exit 0; |
|
|
70 | }); |
|
|
71 | |
|
|
72 | my $inter = AnyEvent->timer (after => 14, cb => sub { |
|
|
73 | print "not ok 5 # inter\n"; |
|
|
74 | print "not ok 6 # inter\n"; |
|
|
75 | $cv2->send; |
68 | }); |
76 | }); |
69 | |
77 | |
70 | $cv2->wait; |
78 | $cv2->wait; |
71 | |
79 | |
72 | print "ok 7\n"; |
80 | print "ok 7\n"; |