mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Julien Ramseier <j.ramseier@gmail.com>
To: musl@lists.openwall.com
Subject: [PATCH] sigtimedwait: allow failing with EINTR
Date: Fri, 23 Feb 2018 13:09:35 +0100	[thread overview]
Message-ID: <B56E055D-9B25-49ED-B194-5E62E02808E0@gmail.com> (raw)

According to POSIX, sigtimedwait(2) is allowed to fail
with EINTR, while sigwait(3) is not, so move the retry loop there.
---

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 12:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 12:09 Julien Ramseier [this message]
2018-02-23 21:45 ` Rich Felker
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=B56E055D-9B25-49ED-B194-5E62E02808E0@gmail.com \
    --to=j.ramseier@gmail.com \
    --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).