summaryrefslogtreecommitdiff
path: root/libc/unistd
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/sleep.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c
index 438f5e282..6a237e3f9 100644
--- a/libc/unistd/sleep.c
+++ b/libc/unistd/sleep.c
@@ -82,6 +82,10 @@ unsigned int sleep (unsigned int seconds)
/* Run nanosleep, with SIGCHLD blocked if SIGCHLD is SIG_IGNed. */
result = nanosleep (&ts, &ts);
+ if (result != 0) {
+ /* Got EINTR. Return remaining time. */
+ result = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
+ }
if (!__sigismember (&set, SIGCHLD)) {
/* We did block SIGCHLD, and old mask had no SIGCHLD bit.
@@ -91,10 +95,6 @@ unsigned int sleep (unsigned int seconds)
sigprocmask (SIG_SETMASK, &set, NULL); /* never fails */
}
- if (result != 0)
- /* Round remaining time. */
- result = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
-
return result;
}
#endif