ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/03_child.t
(Generate patch)

Comparing AnyEvent/t/03_child.t (file contents):
Revision 1.10 by root, Fri May 23 16:36:02 2008 UTC vs.
Revision 1.11 by root, Wed May 13 15:19:43 2009 UTC

1$|=1;
2
3BEGIN { 1BEGIN {
4 # check for broken perls 2 # check for broken perls
5 if ($^O =~ /mswin32/i) { 3 if ($^O =~ /mswin32/i) {
6 my $ok; 4 my $ok;
7 local $SIG{CHLD} = sub { $ok = 1 }; 5 local $SIG{CHLD} = sub { $ok = 1 };
15 } 13 }
16 } 14 }
17} 15}
18 16
19BEGIN { 17BEGIN {
18 $|=1;
20 print "1..7\n" 19 print "1..7\n"
21} 20}
21
22use POSIX ();
22 23
23use AnyEvent; 24use AnyEvent;
24use AnyEvent::Impl::Perl; 25use AnyEvent::Impl::Perl;
25 26
26print "ok 1\n"; 27print "ok 1\n";
36 37
37my $cv = AnyEvent->condvar; 38my $cv = AnyEvent->condvar;
38 39
39unless ($pid) { 40unless ($pid) {
40 print "ok 2\n"; 41 print "ok 2\n";
41 exit 3; 42 POSIX::_exit 3;
42} 43}
43 44
44my $w = AnyEvent->child (pid => $pid, cb => sub { 45my $w = AnyEvent->child (pid => $pid, cb => sub {
45 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; 46 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n";
46 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; 47 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n";
47 $cv->broadcast; 48 $cv->broadcast;
48}); 49});
49 50
50$cv->wait; 51$cv->wait;
51 52
52my $pid2 = fork || exit 7; 53my $pid2 = fork || POSIX::_exit 7;
53 54
54my $cv2 = AnyEvent->condvar; 55my $cv2 = AnyEvent->condvar;
55 56
56my $w2 = AnyEvent->child (pid => 0, cb => sub { 57my $w2 = AnyEvent->child (pid => 0, cb => sub {
57 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; 58 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines