On Wed, May 1, 2013 at 12:57 PM, Manfred Lotz <manfred.l...@arcor.de> wrote:
> 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. > > 'perldoc -f close' hints at this although it could be clearer that > $? could potentially cause close to fail: ... If the filehandle came from a piped open, "close" returns false if one of the other syscalls involved fails or if its program exits with non-zero status. If the only problem was that the program exited non-zero, $! will be set to 0. Closing a pipe also waits for the process executing on the pipe to exit--in case you wish to look at the output of the pipe afterwards--and implicitly puts the exit status value of that command into $? and "${^CHILD_ERROR_NATIVE}". -- Charles DeRykus