about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-11-23 11:20:53 +0100
committerFlorian Weimer <fweimer@redhat.com>2017-11-23 11:20:53 +0100
commitcccb6d4e87053ed63c74aee063fa84eb63ebf7b8 (patch)
treef1098c8ca0e6fa500e1e75f6b1c76650afe507ec /sysdeps/unix/sysv/linux
parent59d2cbb1fe4b8601d5cbd359c3806973eab6c62d (diff)
downloadglibc-cccb6d4e87053ed63c74aee063fa84eb63ebf7b8.tar.gz
glibc-cccb6d4e87053ed63c74aee063fa84eb63ebf7b8.tar.xz
glibc-cccb6d4e87053ed63c74aee063fa84eb63ebf7b8.zip
sigwait: Do not fail with EINTR and return error code [BZ #22478]
Since

commit 8b0e795aaa445e9167aa07b282c5720b35342c07
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Nov 1 11:49:05 2017 -0200

    Simplify Linux sig{timed}wait{info} implementations

sigwait can fail with EINTR.  Applications do not expect that, and the
error code is not documented in POSIX or the manual pages.

This commit restores the previous behavior by retrying the system call
on EINTR.  It also returns the error code, not -1, on the remaing
errors.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/sigwait.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c
index e6fb32a610..443c3ad8e1 100644
--- a/sysdeps/unix/sysv/linux/sigwait.c
+++ b/sysdeps/unix/sysv/linux/sigwait.c
@@ -17,13 +17,20 @@
 
 #include <signal.h>
 #include <sysdep-cancel.h>
+#include <errno.h>
 
 int
 __sigwait (const sigset_t *set, int *sig)
 {
   siginfo_t si;
-  if (__sigtimedwait (set, &si, 0) < 0)
-    return -1;
+  int ret;
+  do
+    ret = __sigtimedwait (set, &si, 0);
+  /* Applications do not expect sigwait to return with EINTR, and the
+     error code is not specified by POSIX.  */
+  while (ret < 0 && errno == EINTR);
+  if (ret < 0)
+    return errno;
   *sig = si.si_signo;
   return 0;
 }