Simplify sigwait64()'s error handling.
But also document that -- other than the EINTRs which it swallows -- it can't actually fail on Linux.
Change-Id: Icb5926e4acf961d4581d5db1b06ef66b68aaf0ad
diff --git a/libc/bionic/signal.cpp b/libc/bionic/signal.cpp
index 5979ed7..77e6acf 100644
--- a/libc/bionic/signal.cpp
+++ b/libc/bionic/signal.cpp
@@ -288,16 +288,14 @@
}
int sigwait64(const sigset64_t* set, int* sig) {
- while (true) {
- // __rt_sigtimedwait can return EAGAIN or EINTR, we need to loop
- // around them since sigwait is only allowed to return EINVAL.
- int result = sigtimedwait64(set, nullptr, nullptr);
- if (result >= 0) {
- *sig = result;
- return 0;
- }
- if (errno != EAGAIN && errno != EINTR) return errno;
- }
+ // sigtimedwait64() doesn't fail with EINVAL on Linux,
+ // and EAGAIN can only happen with a timeout,
+ // so the error reporting here is effectively dead code.
+ ErrnoRestorer errno_restorer;
+ int result = TEMP_FAILURE_RETRY(sigtimedwait64(set, nullptr, nullptr));
+ if (result == -1) return errno;
+ *sig = result;
+ return 0;
}
int sigwaitinfo(const sigset_t* set, siginfo_t* info) {