ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/03_child.t
Revision: 1.2
Committed: Fri Nov 2 19:20:36 2007 UTC (16 years, 8 months ago) by root
Content type: application/x-troff
Branch: MAIN
Changes since 1.1: +13 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 $|=1;
2 root 1.2 BEGIN { print "1..5\n" }
3 root 1.1
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 root 1.2 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 root 1.1
42    
43    
44