X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fio%2Fopenpid.t;h=7c04a29fe81f5ed7890519d740f8fa17b3754334;hb=569bd3158af2276a406770e3d68e76b7da59b730;hp=334bc0d65b3bafa9bdc147ff8d310e63758a8631;hpb=faf89a90b9d9ca73fe8e05bd84a30e7989fb5351;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/io/openpid.t b/t/io/openpid.t index 334bc0d..7c04a29 100755 --- a/t/io/openpid.t +++ b/t/io/openpid.t @@ -9,17 +9,20 @@ BEGIN { chdir 't' if -d 't'; - unshift @INC, '../lib'; + @INC = '../lib'; + if ($^O eq 'dos') { + print "1..0 # Skip: no multitasking\n"; + exit 0; + } } - -use FileHandle; -autoflush STDOUT 1; +use Config; +$| = 1; $SIG{PIPE} = 'IGNORE'; print "1..10\n"; -$perl = "$^X -I../lib"; +$perl = qq[$^X "-I../lib"]; # # commands run 4 perl programs. Two of these programs write a @@ -28,10 +31,8 @@ $perl = "$^X -I../lib"; # the other reader reads one line, waits a few seconds and then # exits to test the waitpid function. # -$cmd1 = qq/$perl -e "use FileHandle; autoflush STDOUT 1; / . - qq/print qq[first process\\n]; sleep 30;"/; -$cmd2 = qq/$perl -e "use FileHandle; autoflush STDOUT 1; / . - qq/print qq[second process\\n]; sleep 30;"/; +$cmd1 = qq/$perl -e "\$|=1; print qq[first process\\n]; sleep 30;"/; +$cmd2 = qq/$perl -e "\$|=1; print qq[second process\\n]; sleep 30;"/; $cmd3 = qq/$perl -e "print <>;"/; # hangs waiting for end of STDIN $cmd4 = qq/$perl -e "print scalar <>;"/; @@ -49,12 +50,15 @@ print "ok 4\n"; print "# pids were $pid1, $pid2, $pid3, $pid4\n"; +my $killsig = 'HUP'; +$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/; + # get message from first process and kill it chomp($from_pid1 = scalar()); print "# child1 returned [$from_pid1]\nnot " unless $from_pid1 eq 'first process'; print "ok 5\n"; -$kill_cnt = kill 'HUP', $pid1; +$kill_cnt = kill $killsig, $pid1; print "not " unless $kill_cnt == 1; print "ok 6\n"; @@ -63,15 +67,16 @@ chomp($from_pid2 = scalar()); print "# child2 returned [$from_pid2]\nnot " unless $from_pid2 eq 'second process'; print "ok 7\n"; -$kill_cnt = kill 'HUP', $pid2, $pid3; +$kill_cnt = kill $killsig, $pid2, $pid3; print "not " unless $kill_cnt == 2; print "ok 8\n"; # send one expected line of text to child process and then wait for it -autoflush FH4 1; +select(FH4); $| = 1; select(STDOUT); + print FH4 "ok 9\n"; print "# waiting for process $pid4 to exit\n"; $reap_pid = waitpid $pid4, 0; print "# reaped pid $reap_pid != $pid4\nnot " - unless $reap_pid == $pid4; + unless $reap_pid == $pid4; print "ok 10\n";