X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fio%2Fpipe.t;h=500832595e31bef6a6307a201672e88dbce28345;hb=569bd3158af2276a406770e3d68e76b7da59b730;hp=4559624ccaf2546afe3943bdce0fda03b18fec28;hpb=ee8c7f5465f003860e2347a2946abacac39bd9b9;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/io/pipe.t b/t/io/pipe.t index 4559624..5008325 100755 --- a/t/io/pipe.t +++ b/t/io/pipe.t @@ -2,7 +2,7 @@ BEGIN { chdir 't' if -d 't'; - unshift @INC, '../lib'; + @INC = '../lib'; require Config; import Config; unless ($Config{'d_fork'}) { print "1..0 # Skip: no fork\n"; @@ -11,7 +11,7 @@ BEGIN { } $| = 1; -print "1..15\n"; +print "1..16\n"; # External program 'tr' assumed. open(PIPE, "|-") || (exec 'tr', 'YX', 'ko'); @@ -99,12 +99,23 @@ else { local $SIG{PIPE} = 'IGNORE'; open NIL, '|true' or die "open failed: $!"; sleep 5; - print NIL 'foo' or die "print failed: $!"; - if (close NIL) { - print "not ok 9\n"; + if (print NIL 'foo') { + # If print was allowed we had better get an error on close + if (close NIL) { + print "not ok 9\n"; + } + else { + print "ok 9\n"; + } } else { - print "ok 9\n"; + # If print failed, the close should be clean + if (close NIL) { + print "ok 9\n"; + } + else { + print "not ok 9\n"; + } } } @@ -174,3 +185,20 @@ if ($? != 42) { } print "ok 15\n"; $? = 0; + +# check that child is reaped if the piped program can't be executed +{ + open NIL, '/no_such_process |'; + close NIL; + + my $child = 0; + eval { + local $SIG{ALRM} = sub { die; }; + alarm 2; + $child = wait; + alarm 0; + }; + + print "not " if $child != -1; + print "ok 16\n"; +}