ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/03_child.t
Revision: 1.6
Committed: Sun Nov 25 13:53:04 2007 UTC (16 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

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