3 unshift @INC, '../lib';
8 unless ($Config{d_fork}) {
9 print "1..0 # no fork\n";
12 eval { use POSIX qw(sys_wait_h) };
14 print "1..0 # no POSIX sys_wait_h\n";
17 eval { use Time::HiRes qw(time) };
19 print "1..0 # no Time::HiRes\n";
31 sub NEG1_PROHIBITED () { 0x01 }
32 sub NEG1_REQUIRED () { 0x02 }
36 my $state = NEG1_PROHIBITED;
38 my $child_pid = fork();
40 # Parent receives a nonzero child PID.
45 while ($count++ < $max_count) {
46 my $begin_time = time();
47 my $ret = waitpid( -1, WNOHANG );
48 my $elapsed_time = time() - $begin_time;
50 printf( "# waitpid(-1,WNOHANG) returned %d after %.2f seconds\n",
51 $ret, $elapsed_time );
52 if ($elapsed_time > 0.5) {
53 printf( "# %.2f seconds in non-blocking waitpid is too long!\n",
59 if ($state & NEG1_PROHIBITED) {
61 print "# waitpid should not have returned -1 here!\n";
65 elsif ($ret == $child_pid) {
66 $state = NEG1_REQUIRED;
69 elsif ($state & NEG1_REQUIRED) {
71 print "# waitpid should have returned -1 here\n";
79 print $ok ? "ok 1\n" : "not ok 1\n";
82 # Child receives a zero PID and can request parent's PID with