From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12543 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] sigtimedwait: allow failing with EINTR Date: Fri, 23 Feb 2018 16:45:31 -0500 Message-ID: <20180223214531.GJ1436@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1519422226 19802 195.159.176.226 (23 Feb 2018 21:43:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 23 Feb 2018 21:43:46 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12559-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 23 22:43:42 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1epL81-0004jU-H3 for gllmg-musl@m.gmane.org; Fri, 23 Feb 2018 22:43:41 +0100 Original-Received: (qmail 19552 invoked by uid 550); 23 Feb 2018 21:45:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 19527 invoked from network); 23 Feb 2018 21:45:43 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12543 Archived-At: On Fri, Feb 23, 2018 at 01:09:35PM +0100, Julien Ramseier wrote: > According to POSIX, sigtimedwait(2) is allowed to fail > with EINTR, while sigwait(3) is not, so move the retry loop there. > --- This is a "may fail", not a "shall fail". Generally we prefer not to support EINTR in cases where it's optional, since getting rid of them with retry loops makes it safe to run on old kernels or pseudo-linux-compat systems where SA_RESTART semantics were/are not actually conforming. Is there a reason you want it to fail with EINTR? Rich > diff --git a/src/signal/sigtimedwait.c b/src/signal/sigtimedwait.c > index 0739986b..97a526da 100644 > --- a/src/signal/sigtimedwait.c > +++ b/src/signal/sigtimedwait.c > @@ -1,13 +1,8 @@ > #include > -#include > #include "syscall.h" > #include "libc.h" > > int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout) > { > - int ret; > - do ret = syscall_cp(SYS_rt_sigtimedwait, mask, > - si, timeout, _NSIG/8); > - while (ret<0 && errno==EINTR); > - return ret; > + return syscall_cp(SYS_rt_sigtimedwait, mask, si, timeout, _NSIG/8); > } > diff --git a/src/signal/sigwait.c b/src/signal/sigwait.c > index c8822eea..53d04803 100644 > --- a/src/signal/sigwait.c > +++ b/src/signal/sigwait.c > @@ -1,10 +1,13 @@ > +#include > #include > > int sigwait(const sigset_t *restrict mask, int *restrict sig) > { > + int ret; > siginfo_t si; > - if (sigtimedwait(mask, &si, 0) < 0) > - return -1; > + do ret = sigtimedwait(mask, &si, 0); > + while (ret<0 && errno==EINTR); > + if (ret<0) return -1; > *sig = si.si_signo; > return 0; > }