From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 19:16:29 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 3BED01065670; Mon, 28 Jun 2010 19:16:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B4ACE8FC16; Mon, 28 Jun 2010 19:16:28 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o5SJGJJI075396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o5SJGJsx076273; Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o5SJGJSX076272; Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 28 Jun 2010 22:16:19 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20100628191619.GF13238@deviant.kiev.zoral.com.ua> References: <201006280833.54224.jhb@freebsd.org> <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> <201006281444.50021.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7Y0jlJGlNwEFz8Iq" Content-Disposition: inline In-Reply-To: <201006281444.50021.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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 19:16:29 -0000 --7Y0jlJGlNwEFz8Iq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 28, 2010 at 02:44:49PM -0400, John Baldwin wrote: > 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=20 > > > with no readers the SIGPIPE signal is posted to the entire process vi= a=20 > > > psignal(). This means that the signal can be delivered to any thread= in the=20 > > > process. However, it seems more intuitive to me that SIGPIPE should = be sent=20 > > > to the "offending" thread similar to signals sent in response to trap= s via=20 > > > trapsignal(). POSIX seems to require this in that the description of= the=20 > > > EPIPE error return value for write(2) and fflush(3) in the Open Group= 's online=20 > > > manpages both say that SIGPIPE should be sent to the current thread i= n=20 > > > addition to returning EPIPE: > > >=20 > > > http://www.opengroup.org/onlinepubs/000095399/functions/write.html > > >=20 > > > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html > > >=20 > > > 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. >=20 > 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. >=20 > This patch can be found at http://www.freebsd.org/~jhb/patches/tdsignal.p= atch It seems that tdsendsignal() call in trapsignal() can be replaced by tdksignal(), unless I am mistaken. The same for psignal_event(). There is also a reference to tdsignal() in subr_sleepqueue.c comment, that is probably better to replace with tdsendsignal(). >=20 > 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 Looks good. --7Y0jlJGlNwEFz8Iq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkwo9QMACgkQC3+MBN1Mb4g2uQCgoR6eJFZG7p/nAnavGvFR7zwm iqoAoLSKIG5ezIlVejXdB3/BINFaFJZl =FuA1 -----END PGP SIGNATURE----- --7Y0jlJGlNwEFz8Iq--