From owner-freebsd-threads@FreeBSD.ORG Thu Sep 9 22:55:25 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 26C8B106564A; Thu, 9 Sep 2010 22:55:25 +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 DF1188FC19; Thu, 9 Sep 2010 22:55:24 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 3E4061DD648; Fri, 10 Sep 2010 00:55:24 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 3303717248; Fri, 10 Sep 2010 00:55:24 +0200 (CEST) Date: Fri, 10 Sep 2010 00:55:24 +0200 From: Jilles Tjoelker To: David Xu Message-ID: <20100909225524.GC48144@stack.nl> References: <20100906220041.GA4729@stack.nl> <4C86787E.6070908@freebsd.org> <20100908175609.GA30144@stack.nl> <4C88EF47.4010906@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C88EF47.4010906@freebsd.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-threads@freebsd.org Subject: Re: 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: Thu, 09 Sep 2010 22:55:25 -0000 On Thu, Sep 09, 2010 at 02:29:27PM +0000, David Xu wrote: > Jilles Tjoelker wrote: > > On Tue, Sep 07, 2010 at 05:38:06PM +0000, David Xu wrote: > >> Jilles Tjoelker wrote: > >>> 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.) > >> A system call can not return EINTR is not flexible, I think why don't > >> we fix it in libc and libthr, but let kernel returns EINTR? > >> I have worked out a patch: > >> http://people.freebsd.org/~davidxu/patch/sigwait.diff > > The idea and patch seem sensible. Some man page changes seem in order > > though: sigwaitinfo.2 should mention this difference between sigwait() > > and sigwaitinfo() more explicitly. > problem is I still want to know which OS does not return EINTR ? > it seems I can not find one on net, so is it an accident of the > specification group? Recent versions of glibc do this. They implement sigwait/sigwaitinfo/sigtimedwait based on a single extended sigtimedwait system call; sigwait differs from the others by retrying when it gets EINTR. This is not documented very well in man pages (for example, man sigwait might get you an ancient LinuxThreads man page). One reference: http://lkml.indiana.edu/hypermail/linux/kernel/0508.0/0181.html Google also provides various examples of applications that treated any sigwait() error as fatal and needed to be changed to work reliably on systems where sigwait() may return EINTR (not just FreeBSD). -- Jilles Tjoelker