On Wed, 1 May 2013 12:00:18 -0700
Charles DeRykus <dery...@gmail.com> wrote:

> > ...
> > Thanks for your detailed explanations. I think that close should
> > work as I cannot see any reason why a failure of a command closes
> > the pipe prematurely.
> 
> Actually,  everything is ok until the close which checks both the
> status from reaping the child and the close itself:
> 

OK, the issue is that close is more than just close. Looking from this
side it works like designed.


> The open can actually  be written like this for more into:
> 
> my $pid = open(my $fh, '-|', ... or die ...;   # pid is forked
> process id warn "made it past open ok...\n";
> close( $fh) or die "child $pid status=$?  close error=$!";
> 
> So the close can be written  to see whether the child  process had a
> problem, ie, $?  or whether it was  the 'close' itself that failed,
> ie, $!.
> 
> Output without 'autodie':
>  made it past open ok...
>  child 4872 status=256  close error=Inappropriate I/O control
> operation at...
> 
> With autodie though, the message is much more obscure:
>  made it past ok...
>  Can't close(GLOB(0x64dcf8)) filehandle: '' at...
> 

It seems that the best is to disable autodie for this particular close.


-- 
Manfred


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to