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, 6 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

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