1 | $|=1; |
|
|
2 | BEGIN { |
1 | BEGIN { |
|
|
2 | # check for broken perls |
|
|
3 | if ($^O =~ /mswin32/i) { |
|
|
4 | my $ok; |
|
|
5 | local $SIG{CHLD} = sub { $ok = 1 }; |
|
|
6 | kill 'CHLD', 0; |
|
|
7 | |
|
|
8 | unless ($ok) { |
|
|
9 | print <<EOF; |
|
|
10 | 1..0 # Your perl interpreter is badly BROKEN. Child watchers will not work, ever. Try upgrading to a newer perl or a working perl (cygwin's perl is known to work). If that is not an option, you should be able to use the remaining functionality of AnyEvent, but child watchers WILL NOT WORK. |
|
|
11 | EOF |
|
|
12 | exit 0; |
|
|
13 | } |
|
|
14 | } |
|
|
15 | } |
|
|
16 | |
|
|
17 | BEGIN { |
|
|
18 | $|=1; |
3 | print "1..7\n" |
19 | print "1..7\n" |
4 | } |
20 | } |
|
|
21 | |
|
|
22 | use POSIX (); |
5 | |
23 | |
6 | use AnyEvent; |
24 | use AnyEvent; |
7 | use AnyEvent::Impl::Perl; |
25 | use AnyEvent::Impl::Perl; |
8 | |
26 | |
9 | print STDERR <<EOF; |
27 | $AnyEvent::MAX_SIGNAL_LATENCY = 1; |
10 | |
|
|
11 | If the following test hangs for a long time you either found a bug in |
|
|
12 | AnyEvent or, more likely, you have a defective perl (most windows perl |
|
|
13 | distros are broken, cygwin perl works). If you do not rely on child |
|
|
14 | handlers you can force the installation of this module and the rest will |
|
|
15 | likely work. Otherwise upgrading to a working perl is recommended. |
|
|
16 | EOF |
|
|
17 | |
28 | |
18 | print "ok 1\n"; |
29 | print "ok 1\n"; |
19 | |
30 | |
20 | AnyEvent::detect; # force-load event model |
31 | AnyEvent::detect; # force-load event model |
21 | |
32 | |
… | |
… | |
28 | |
39 | |
29 | my $cv = AnyEvent->condvar; |
40 | my $cv = AnyEvent->condvar; |
30 | |
41 | |
31 | unless ($pid) { |
42 | unless ($pid) { |
32 | print "ok 2\n"; |
43 | print "ok 2\n"; |
33 | exit 3; |
44 | POSIX::_exit 3; |
34 | } |
45 | } |
35 | |
46 | |
36 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
47 | my $w = AnyEvent->child (pid => $pid, cb => sub { |
37 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
48 | print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; |
38 | 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"; |
39 | $cv->broadcast; |
50 | $cv->broadcast; |
40 | }); |
51 | }); |
41 | |
52 | |
42 | $cv->wait; |
53 | $cv->wait; |
43 | |
54 | |
44 | my $pid2 = fork || exit 7; |
55 | my $pid2 = fork || POSIX::_exit 7; |
45 | |
56 | |
46 | my $cv2 = AnyEvent->condvar; |
57 | my $cv2 = AnyEvent->condvar; |
47 | |
58 | |
48 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
59 | my $w2 = AnyEvent->child (pid => 0, cb => sub { |
49 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |
60 | print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; |