ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/03_child.t
Revision: 1.3
Committed: Sat Nov 3 09:35:20 2007 UTC (16 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-2_55
Changes since 1.2: +6 -4 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 $pid == $_[0] ? "" : "not ", "ok 3\n";
24 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4\n";
25 $cv->broadcast;
26 });
27
28 $cv->wait;
29
30 my $pid2 = fork || exit 7;
31
32 my $cv2 = AnyEvent->condvar;
33
34 my $w2 = AnyEvent->child (pid => 0, cb => sub {
35 print $pid2 == $_[0] ? "" : "not ", "ok 5\n";
36 print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6\n";
37 $cv2->broadcast;
38 });
39
40 $cv2->wait;
41
42 print "ok 7\n";
43
44
45
46