note
ikegami
<p>That's completely wrong.
<p>1. Closing one end of a pipe doesn't cause close on the other end to return an error.
<c>
$ perl -E'
pipe($r, $w) or die $!;
close($w) or die $!;
close($r) or die $!;
say "ok";
'
ok
</c>
<p>2. Closing a pipe created by <c>open(my $fh, '|-', ...)</c> reads the process (calls <c>wait</c>). It's very appropriate to do this, whether the pipe is closed or not. Closing such a handle returns the same thing as <c>system</c>.
<c>
$ perl -E'
open(my $fh, "|-", "perl", "-e", "exit 123") or die $!;
close($fh);
die("$!\n") if $? == -1;
die("Signal ".( $? & 0x7F )."\n") if $? & 0x7F;
die("Error ".( $? >> 8 )."\n") if $? >> 8;
say "ok";
'
Error 123
</c>
1140381
1140387