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.9 by root, Fri Apr 25 13:32:39 2008 UTC vs.
Revision 1.15 by root, Sat Jul 18 00:05:29 2009 UTC

1$|=1; 1use POSIX ();
2BEGIN {
3 print "1..7\n"
4}
5 2
6use AnyEvent; 3use AnyEvent;
7use AnyEvent::Impl::Perl; 4use AnyEvent::Impl::Perl;
8 5
9print STDERR <<EOF; 6BEGIN {
7 # check for broken perls
8 if ($^O =~ /mswin32/i) {
9 my $ok;
10 local $SIG{CHLD} = sub { $ok = 1 };
11 kill 'CHLD', 0;
10 12
11If the following test hangs for a long time you either found a bug in 13 unless ($ok) {
12AnyEvent or, more likely, you have a defective perl (most windows perl 14 print <<EOF;
13distros are broken, cygwin perl works). If you do not rely on child 151..0 # Your perl interpreter is badly BROKEN. Child watchers will not work, ever. Try upgrading to a newer perl or a working perl (cygwin's perl is known to work). If that is not an option, you should be able to use the remaining functionality of AnyEvent, but child watchers WILL NOT WORK.
14handlers you can force the installation of this module and the rest will
15likely work. Otherwise upgrading to a working perl is recommended.
16EOF 16EOF
17 exit 0;
18 }
19 }
20}
21
22$| = 1; print "1..7\n";
23
24$AnyEvent::MAX_SIGNAL_LATENCY = 1;
17 25
18print "ok 1\n"; 26print "ok 1\n";
19 27
20AnyEvent::detect; # force-load event model 28AnyEvent::detect; # force-load event model
21 29
28 36
29my $cv = AnyEvent->condvar; 37my $cv = AnyEvent->condvar;
30 38
31unless ($pid) { 39unless ($pid) {
32 print "ok 2\n"; 40 print "ok 2\n";
33 exit 3; 41 POSIX::_exit 3;
34} 42}
35 43
36my $w = AnyEvent->child (pid => $pid, cb => sub { 44my $w = AnyEvent->child (pid => $pid, cb => sub {
37 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; 45 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n";
38 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; 46 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n";
39 $cv->broadcast; 47 $cv->broadcast;
40}); 48});
41 49
42$cv->wait; 50$cv->wait;
43 51
44my $pid2 = fork || exit 7; 52my $pid2 = fork || POSIX::_exit 7;
45 53
46my $cv2 = AnyEvent->condvar; 54my $cv2 = AnyEvent->condvar;
47 55
48my $w2 = AnyEvent->child (pid => 0, cb => sub { 56my $w2 = AnyEvent->child (pid => 0, cb => sub {
49 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; 57 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines