mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] sigtimedwait: allow failing with EINTR
Date: Fri, 23 Feb 2018 16:45:31 -0500	[thread overview]
Message-ID: <20180223214531.GJ1436@brightrain.aerifal.cx> (raw)
In-Reply-To: <B56E055D-9B25-49ED-B194-5E62E02808E0@gmail.com>

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 <signal.h>
> -#include <errno.h>
>  #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 <errno.h>
>  #include <signal.h>
>  
>  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;
>  }


  reply	other threads:[~2018-02-23 21:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 12:09 Julien Ramseier
2018-02-23 21:45 ` Rich Felker [this message]
2018-02-24 10:45   ` Julien Ramseier
2018-02-24 14:39     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180223214531.GJ1436@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).