--- AnyEvent/t/03_child.t 2007/11/02 19:20:36 1.2 +++ AnyEvent/t/03_child.t 2009/07/09 22:37:53 1.13 @@ -1,43 +1,81 @@ -$|=1; -BEGIN { print "1..5\n" } +BEGIN { + # check for broken perls + if ($^O =~ /mswin32/i) { + my $ok; + local $SIG{CHLD} = sub { $ok = 1 }; + kill 'CHLD', 0; + + unless ($ok) { + print <timer (after => 2, cb => sub { }); +#my $timer = AnyEvent->timer (after => 2, cb => sub { }); my $cv = AnyEvent->condvar; unless ($pid) { print "ok 2\n"; - exit 3; + POSIX::_exit 3; } my $w = AnyEvent->child (pid => $pid, cb => sub { - print 3 == ($? >> 8) ? "" : "not ", "ok 3\n"; + print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; + print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; $cv->broadcast; }); $cv->wait; -fork || exit 7; +my $pid2 = fork || POSIX::_exit 7; my $cv2 = AnyEvent->condvar; my $w2 = AnyEvent->child (pid => 0, cb => sub { - print 7 == ($? >> 8) ? "" : "not ", "ok 4\n"; + print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; + print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; $cv2->broadcast; }); +my $error = AnyEvent->timer (after => 15, cb => sub { + print <timer (after => 14, cb => sub { + print "not ok 5 # inter\n"; + print "not ok 6 # inter\n"; + $cv2->send; +}); + $cv2->wait; -print "ok 5\n"; +print "ok 7\n";