Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 23 Feb 2018 16:45:31 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] sigtimedwait: allow failing with EINTR

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;
>  }

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.