From owner-freebsd-stable@FreeBSD.ORG Sat Oct 17 17:55:56 2009 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF65B1065679 for ; Sat, 17 Oct 2009 17:55:56 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id A00928FC1C for ; Sat, 17 Oct 2009 17:55:56 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 3736E35A83E; Sat, 17 Oct 2009 19:55:55 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 25810228BE; Sat, 17 Oct 2009 19:55:55 +0200 (CEST) Date: Sat, 17 Oct 2009 19:55:55 +0200 From: Jilles Tjoelker To: "Mikhail T." Message-ID: <20091017175555.GA76378@stack.nl> References: <4AD9F4ED.2050002@aldan.algebra.com> <20091017172718.GJ2160@deviant.kiev.zoral.com.ua> <4ADA01C2.3000303@aldan.algebra.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ADA01C2.3000303@aldan.algebra.com> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Kostik Belousov , stable@freebsd.org Subject: Re: Can close-ing a pipe trigger a SIGPIPE? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2009 17:55:57 -0000 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