Can close-ing a pipe trigger a SIGPIPE?

Kostik Belousov kostikbel at gmail.com
Sat Oct 17 17:27:39 UTC 2009


On Sat, Oct 17, 2009 at 12:46:37PM -0400, Mikhail T. wrote:
> Hello!
> 
> I'm investigating a problem caused by (what seems like a spurious)
> SIGPIPE. The program creates a child process using pipe, exchanges a few
> messages with the child (via write and read) and closes the pipe.
> 
> Some times -- in about 60% of the cases -- this causes a SIGPIPE to be
> delivered to the parent...
> 
> Now, it is quite possible for the child to have already exited by the
> time the parent closes its end of the pipe -- but why should that cause
> a SIGPIPE, unless the parent tries to write something to the widowed
> pipe, which it does not?
> 
> >From pipe(2):
> 
>      A pipe that has had an end closed is considered widowed.  Writing
> on such
>      a pipe causes the writing process to receive a SIGPIPE signal.
> 
> There is no other mention of SIGPIPE in that manual page...
> 
> I set SIGPIPE on ignore around the pipe-closing as a work-around, but I
> think, this is a bug...
> 
> The thing is part of TclX' self-test (test signal-3.0) -- and it was not
> dying from SIGPIPE before the FreeBSD-7.x, as far as I can remember...
> It still seems to be fine on Linux...
> 
> Have there been any changes in this area in FreeBSD? Thanks!

Take ktrace of both parent and child.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20091017/c0395706/attachment.pgp


More information about the freebsd-stable mailing list