Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Oct 2009 19:55:55 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        "Mikhail T." <mi+thun@aldan.algebra.com>
Cc:        Kostik Belousov <kostikbel@gmail.com>, stable@freebsd.org
Subject:   Re: Can close-ing a pipe trigger a SIGPIPE?
Message-ID:  <20091017175555.GA76378@stack.nl>
In-Reply-To: <4ADA01C2.3000303@aldan.algebra.com>
References:  <4AD9F4ED.2050002@aldan.algebra.com> <20091017172718.GJ2160@deviant.kiev.zoral.com.ua> <4ADA01C2.3000303@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091017175555.GA76378>