From owner-freebsd-threads@FreeBSD.ORG Mon Sep 6 22:00:42 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61F3A10656C6; Mon, 6 Sep 2010 22:00:42 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 2B50D8FC13; Mon, 6 Sep 2010 22:00:42 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 87C261DD659; Tue, 7 Sep 2010 00:00:41 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 6006417328; Tue, 7 Sep 2010 00:00:41 +0200 (CEST) Date: Tue, 7 Sep 2010 00:00:41 +0200 From: Jilles Tjoelker To: freebsd-threads@freebsd.org, David Xu Message-ID: <20100906220041.GA4729@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: sigwait() cancellation point 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, 06 Sep 2010 22:00:42 -0000 Our sigwait() implementation may not be POSIX-compliant as it returns EINTR when it is interrupted by a caught signal. (Unfortunately I can only find this in SUSv4 in the Rationale, B.2.3 Error Numbers, Disallowing Return of the [EINTR] Error Code; the sigwait() page in XSH does not list an [EINTR] error condition, but does not prohibit one either like pthread_mutex_lock() and various others do.) However, libthr's wrapper for sigwait() relies on EINTR. To keep the possibility of changing this to be what POSIX intends, it would be nice to remove this dependency. One way is to include SIGCANCEL in the set of waited signals, but this requires two additional syscalls to mask/unmask SIGCANCEL. Another way is to use sigwaitinfo() in the wrapper, which is permitted to return [EINTR]. If [EINTR] is removed from the kernel sigwait(), looping on [EINTR] can then be implemented in the wrapper. Calling pthread_exit from the SIGCANCEL handler is not possible as this leaves the program in doubt about any signal consumed by sigwait(). -- Jilles Tjoelker