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.21 by root, Tue Aug 2 22:07:16 2011 UTC vs.
Revision 1.24 by root, Fri Mar 30 04:25:11 2012 UTC

38 #my $timer = AnyEvent->timer (after => 2, cb => sub { }); 38 #my $timer = AnyEvent->timer (after => 2, cb => sub { });
39 39
40 my $cv = AnyEvent->condvar; 40 my $cv = AnyEvent->condvar;
41 41
42 unless ($pid) { 42 unless ($pid) {
43 print "ok ${it}2\n"; 43 print "ok ${it}2 # child $$\n";
44
45 # POE hits a race condition when the child dies too quickly
46 # because it checks for child exit before installing the signal handler.
47 # seen in version 1.352 - earlier versions had the same bug, but
48 # polled for child exits regularly, so only caused a delay.
49 sleep 1 if $AnyEvent::MODEL eq "AnyEvent::Impl::POE";
50
44 POSIX::_exit 3; 51 POSIX::_exit 3;
45 } 52 }
46
47 my $w = AnyEvent->child (pid => $pid, cb => sub { 53 my $w = AnyEvent->child (pid => $pid, cb => sub {
48 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n"; 54 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n";
49 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n"; 55 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n";
50 $cv->broadcast; 56 $cv->broadcast;
51 }); 57 });
52 58
53 $cv->recv; 59 $cv->recv;
54 60
55 my $pid2 = fork || POSIX::_exit 7; 61 my $pid2 = fork || do {
62 sleep 1 if $AnyEvent::MODEL eq "AnyEvent::Impl::POE";
63 POSIX::_exit 7;
64 };
56 65
57 my $cv2 = AnyEvent->condvar; 66 my $cv2 = AnyEvent->condvar;
58 67
59 # Glib is the only model that doesn't support pid == 0 68 # Glib is the only model that doesn't support pid == 0
60 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0; 69 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines