mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] sigtimedwait: allow failing with EINTR
@ 2018-02-23 12:09 Julien Ramseier
  2018-02-23 21:45 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Ramseier @ 2018-02-23 12:09 UTC (permalink / raw)
  To: musl

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-24 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 12:09 [PATCH] sigtimedwait: allow failing with EINTR Julien Ramseier
2018-02-23 21:45 ` Rich Felker
2018-02-24 10:45   ` Julien Ramseier
2018-02-24 14:39     ` Rich Felker

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).