summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/posix/Select.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/rts/posix/Select.c b/rts/posix/Select.c
index 1edf6bc690..dc40b706d8 100644
--- a/rts/posix/Select.c
+++ b/rts/posix/Select.c
@@ -196,10 +196,19 @@ awaitEvent(rtsBool wait)
ptv = NULL;
}
- /* Check for any interesting events */
-
- while ((numFound = select(maxfd+1, &rfd, &wfd, NULL, ptv)) < 0) {
- if (errno != EINTR) {
+ while (1) { // repeat the select on EINTR
+
+ // Disable the timer signal while blocked in
+ // select(), to conserve power. (#1623, #5991)
+ if (wait) stopTimer();
+
+ numFound = select(maxfd+1, &rfd, &wfd, NULL, ptv);
+
+ if (wait) startTimer();
+
+ if (numFound >= 0) break;
+
+ if (errno != EINTR) {
/* Handle bad file descriptors by unblocking all the
waiting threads. Why? Because a thread might have been
a bit naughty and closed a file descriptor while another