in reply to close fails(?) occasionally when closing handle of a reading pipe?

If you close the reading end of a pipe before the process writing to it has finished, then the writing process will receive a SIGPIPE, and unless it catches this signal, it will die. This dying causes close() on the reader to return false, with $? set to the signal number.

Note that pipes usually have a 4K buffer, so its possible for the writer to have finished writing and exited cleanly before the reader closes the pipe, even if all the data hasn't been read.

Dave.

  • Comment on Re: close fails(?) occasionally when closing handle of a reading pipe?

Replies are listed 'Best First'.
Re^2: close fails(?) occasionally when closing handle of a reading pipe?
by linuxer (Curate) on May 15, 2008 at 18:01 UTC
    Also thank you for your reply.