in reply to close() on opened pipe fails in forked child
Is there a particular reason you have to die on a close failure? I assume the close is necessary for a buffer flush. Is there a particular reason you need a global filehandle? This issue would seem to go away if you use Indirect Filehandles and let the Perl garbage collection resolve the closing.
open my $pipe, "| cat" or die $!; my $pid = fork(); if( $pid == 0 ) { # child print $pipe "Child\n"; exit 0; } sleep 1; print $pipe "Parent\n"; my $reaped = waitpid(-1, 0 ); print "pid $reaped\n";
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: close() on opened pipe fails in forked child
by saintmike (Vicar) on May 09, 2013 at 20:04 UTC | |
by kennethk (Abbot) on May 09, 2013 at 20:34 UTC |