1 | $|=1; |
|
|
2 | |
|
|
3 | BEGIN { |
1 | BEGIN { |
4 | # check for broken perls |
2 | # check for broken perls |
5 | if ($^O =~ /mswin32/i) { |
3 | if ($^O =~ /mswin32/i) { |
6 | my $ok; |
4 | my $ok; |
7 | local $SIG{CHLD} = sub { $ok = 1 }; |
5 | local $SIG{CHLD} = sub { $ok = 1 }; |
… | |
… | |
15 | } |
13 | } |
16 | } |
14 | } |
17 | } |
15 | } |
18 | |
16 | |
19 | BEGIN { |
17 | BEGIN { |
|
|
18 | $|=1; |
20 | print "1..7\n" |
19 | print "1..7\n" |
21 | } |
20 | } |
22 | |
21 | |
|
|
22 | use POSIX (); |
|
|
23 | |
23 | use AnyEvent; |
24 | use AnyEvent; |
24 | use AnyEvent::Impl::POE; |
25 | use AnyEvent::Impl::POE; $^W = 0; |
25 | |
26 | |
26 | print "ok 1\n"; |
27 | print "ok 1\n"; |
27 | |
28 | |
28 | AnyEvent::detect; # force-load event model |
29 | AnyEvent::detect; # force-load event model |
29 | |
30 | |
… | |
… | |
36 | |
37 | |
37 | my $cv = AnyEvent->condvar; |
38 | my $cv = AnyEvent->condvar; |
38 | |
39 | |
39 | unless ($pid) { |
40 | unless ($pid) { |
40 | print "ok 2\n"; |
41 | print "ok 2\n"; |
41 | exit 3; |
42 | POSIX::_exit 3; |
42 | } |
43 | } |
43 | |
44 | |
44 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
45 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
45 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
46 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
46 | print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; |
47 | print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; |
47 | $cv->broadcast; |
48 | $cv->broadcast; |
48 | }); |
49 | }); |
49 | |
50 | |
50 | $cv->wait; |
51 | $cv->wait; |
51 | |
52 | |
52 | my $pid2 = fork || exit 7; |
53 | my $pid2 = fork || POSIX::_exit 7; |
53 | |
54 | |
54 | my $cv2 = AnyEvent->condvar; |
55 | my $cv2 = AnyEvent->condvar; |
55 | |
56 | |
56 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
57 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
57 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |
58 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |
58 | print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; |
59 | print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; |
59 | $cv2->broadcast; |
60 | $cv2->broadcast; |
60 | }); |
61 | }); |
61 | |
62 | |
62 | my $error = AnyEvent->timer (after => 5, cb => sub { |
63 | my $error = AnyEvent->timer (after => 15, cb => sub { |
63 | print <<EOF; |
64 | print <<EOF; |
64 | 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"; |
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"; |
65 | EOF |
66 | EOF |
66 | exit 0; |
67 | exit 0; |
|
|
68 | }); |
|
|
69 | |
|
|
70 | my $inter = AnyEvent->timer (after => 14, cb => sub { |
|
|
71 | print "not ok 5 # inter\n"; |
|
|
72 | print "not ok 6 # inter\n"; |
|
|
73 | $cv2->send; |
67 | }); |
74 | }); |
68 | |
75 | |
69 | $cv2->wait; |
76 | $cv2->wait; |
70 | |
77 | |
71 | print "ok 7\n"; |
78 | print "ok 7\n"; |