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.