1 |
$|=1; |
2 |
BEGIN { print "1..5\n" } |
3 |
|
4 |
use AnyEvent; |
5 |
|
6 |
print "ok 1\n"; |
7 |
|
8 |
my $pid = fork; |
9 |
|
10 |
defined $pid or die "unable to fork"; |
11 |
|
12 |
# work around Tk bug until it has been fixed. |
13 |
my $timer = AnyEvent->timer (after => 2, cb => sub { }); |
14 |
|
15 |
my $cv = AnyEvent->condvar; |
16 |
|
17 |
unless ($pid) { |
18 |
print "ok 2\n"; |
19 |
exit 3; |
20 |
} |
21 |
|
22 |
my $w = AnyEvent->child (pid => $pid, cb => sub { |
23 |
print 3 == ($? >> 8) ? "" : "not ", "ok 3\n"; |
24 |
$cv->broadcast; |
25 |
}); |
26 |
|
27 |
$cv->wait; |
28 |
|
29 |
fork || exit 7; |
30 |
|
31 |
my $cv2 = AnyEvent->condvar; |
32 |
|
33 |
my $w2 = AnyEvent->child (pid => 0, cb => sub { |
34 |
print 7 == ($? >> 8) ? "" : "not ", "ok 4\n"; |
35 |
$cv2->broadcast; |
36 |
}); |
37 |
|
38 |
$cv2->wait; |
39 |
|
40 |
print "ok 5\n"; |
41 |
|
42 |
|
43 |
|
44 |
|