diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-03-28 14:29:37 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-03-31 05:51:10 +1100 |
commit | 7aa4c52f9df1705258f43f9c003c17af97401693 (patch) | |
tree | 5e808a6ac030f73986d2c633e9ff50af9cd1e845 | |
parent | 973633ae3327238162ce0e497ce049265ea3e6ee (diff) | |
download | haskell-7aa4c52f9df1705258f43f9c003c17af97401693.tar.gz |
rts/posix/Itimer.c: Handle EINTR when reading timerfd
Commit 8626d76a72 added checking of the return value when reading from
the `timer_fd` and calling `sysErrorBelch` to print a warning message.
However some error causes (like EINTR) are benign and should just be
ignored.
Test Plan: validate
Reviewers: hvr, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2040
-rw-r--r-- | rts/posix/Itimer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index b8332957af..8915446814 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -202,10 +202,15 @@ static void *itimer_thread_func(void *_handle_tick) while (1) { if (USE_TIMERFD_FOR_ITIMER) { - if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) - sysErrorBelch("Itimer: read(timer_fd) failed"); + if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) { + if (errno != EINTR) { + sysErrorBelch("Itimer: read(timerfd) failed"); + } + } } else { - usleep(TimeToUS(itimer_interval)); + if (usleep(TimeToUS(itimer_interval)) != 0 && errno != EINTR) { + sysErrorBelch("usleep(TimeToUS(itimer_interval) failed"); + } } switch (itimer_state) { case RUNNING: @@ -222,7 +227,7 @@ static void *itimer_thread_func(void *_handle_tick) return NULL; } } - return NULL; + return NULL; // Never reached. } #endif |