From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 18:44:55 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8E24106564A for ; Mon, 28 Jun 2010 18:44:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BDD498FC18 for ; Mon, 28 Jun 2010 18:44:55 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 5C9A446B2E; Mon, 28 Jun 2010 14:44:55 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8D00A8A03C; Mon, 28 Jun 2010 14:44:50 -0400 (EDT) From: John Baldwin To: Kostik Belousov Date: Mon, 28 Jun 2010 14:44:49 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201006280833.54224.jhb@freebsd.org> <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> In-Reply-To: <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201006281444.50021.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 28 Jun 2010 14:44:50 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 18:44:56 -0000 On Monday 28 June 2010 10:05:34 am Kostik Belousov wrote: > On Mon, Jun 28, 2010 at 08:33:54AM -0400, John Baldwin wrote: > > Currently when a thread performs a write(2) on a disconnected socket or a FIFO > > with no readers the SIGPIPE signal is posted to the entire process via > > psignal(). This means that the signal can be delivered to any thread in the > > process. However, it seems more intuitive to me that SIGPIPE should be sent > > to the "offending" thread similar to signals sent in response to traps via > > trapsignal(). POSIX seems to require this in that the description of the > > EPIPE error return value for write(2) and fflush(3) in the Open Group's online > > manpages both say that SIGPIPE should be sent to the current thread in > > addition to returning EPIPE: > > > > http://www.opengroup.org/onlinepubs/000095399/functions/write.html > > > > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html > > > > I have an untested (only compiled) patch below: > > I think the patch is right, but, as you note, having a dedicated > function that wraps automatic ksi initialization and tdsignal() > call would be even better. Ok, what I've done is to rename tdsignal() to tdsendsignals() and make it private to kern_sig.c. I then added 'tdsignal()' and 'tdksignal()' to the public KPI to mirror the existing psignal() and pksignal() routines. This patch can be found at http://www.freebsd.org/~jhb/patches/tdsignal.patch I then reworked the sigpipe patch to just convert calls to psignal() to tdsignal() instead. It is at http://www.freebsd.org/~jhb/patches/sigpipe.patch -- John Baldwin