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