Can close-ing a pipe trigger a SIGPIPE?

Mikhail T. mi+thun at aldan.algebra.com
Sat Oct 17 16:46:43 UTC 2009


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!

    -mi



More information about the freebsd-stable mailing list