Can close-ing a pipe trigger a SIGPIPE?
Jilles Tjoelker
jilles at stack.nl
Sat Oct 17 17:55:57 UTC 2009
On Sat, Oct 17, 2009 at 01:41:22PM -0400, Mikhail T. wrote:
> Kostik Belousov wrote:
> > Take ktrace of both parent and child.
> Great idea! Here is the kdump's listing for both (after ktrace -i):
> http://aldan.algebra.com/~mi/tmp/tclx-kdump.txt
> (it is large, so be sure to use a compressing browser). Once loaded,
> look for substring:
> Error SIGPIPE signal received while closing file5.
> The parent process-ID is 92722. The child -- 92723. Thanks! Yours,
The interesting part of the ktrace:
92723 tclsh8.5 CALL exit(0)
92722 tclsh8.5 CALL sigaction(SIGPIPE,0x7fffffffa9e0,0)
92722 tclsh8.5 RET sigaction 0
92722 tclsh8.5 CALL write(0x4,0x800e24028,0)
92722 tclsh8.5 RET write -1 errno 32 Broken pipe
92722 tclsh8.5 PSIG SIGPIPE caught handler=0x800f126d0 mask=0x0
code=0x0
92722 tclsh8.5 CALL sigreturn(0x7fffffffa0c0)
92722 tclsh8.5 RET sigreturn JUSTRETURN
92722 tclsh8.5 CALL close(0x5)
92722 tclsh8.5 RET close 0
92722 tclsh8.5 CALL close(0x4)
92722 tclsh8.5 RET close 0
It seems unwise to assume that a write(2) of 0 bytes is a noop.
Even if it is, doing it is a waste of a system call.
--
Jilles Tjoelker
More information about the freebsd-stable
mailing list