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

Comparing AnyEvent/t/69_ev_03_child.t (file contents):
Revision 1.10 by root, Tue Aug 2 22:07:18 2011 UTC vs.
Revision 1.15 by root, Tue Jul 30 23:14:34 2013 UTC

17 } 17 }
18 } 18 }
19} 19}
20 20
21use AnyEvent; 21use AnyEvent;
22
23 BEGIN { $^W = 0 }
24 BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) }
22BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable 25 BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable\n}), exit 0) }
23}), exit 0) } 26
27
24 28
25$| = 1; print "1..50\n"; 29$| = 1; print "1..50\n";
26 30
27$AnyEvent::MAX_SIGNAL_LATENCY = 0.2; 31$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
28 32
39 #my $timer = AnyEvent->timer (after => 2, cb => sub { }); 43 #my $timer = AnyEvent->timer (after => 2, cb => sub { });
40 44
41 my $cv = AnyEvent->condvar; 45 my $cv = AnyEvent->condvar;
42 46
43 unless ($pid) { 47 unless ($pid) {
44 print "ok ${it}2\n"; 48 print "ok ${it}2 # child $$\n";
49
50 # POE hits a race condition when the child dies too quickly
51 # because it checks for child exit before installing the signal handler.
52 # seen in version 1.352 - earlier versions had the same bug, but
53 # polled for child exits regularly, so only caused a delay.
54 sleep 1 if $AnyEvent::MODEL eq "AnyEvent::Impl::POE";
55
45 POSIX::_exit 3; 56 POSIX::_exit 3;
46 } 57 }
47
48 my $w = AnyEvent->child (pid => $pid, cb => sub { 58 my $w = AnyEvent->child (pid => $pid, cb => sub {
49 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n"; 59 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n";
50 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n"; 60 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n";
51 $cv->broadcast; 61 $cv->broadcast;
52 }); 62 });
53 63
54 $cv->recv; 64 $cv->recv;
55 65
56 my $pid2 = fork || POSIX::_exit 7; 66 my $pid2 = fork || do {
67 sleep 1 if $AnyEvent::MODEL eq "AnyEvent::Impl::POE";
68 POSIX::_exit 7;
69 };
57 70
58 my $cv2 = AnyEvent->condvar; 71 my $cv2 = AnyEvent->condvar;
59 72
60 # Glib is the only model that doesn't support pid == 0 73 # Glib is the only model that doesn't support pid == 0
61 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0; 74 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines