summaryrefslogtreecommitdiff
path: root/libc/unistd
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/sleep.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c
index f8c57fc89..2b3187ebc 100644
--- a/libc/unistd/sleep.c
+++ b/libc/unistd/sleep.c
@@ -29,12 +29,14 @@
* fine unless you are messing with SIGCHLD... */
unsigned int sleep (unsigned int sec)
{
+ unsigned int res;
struct timespec ts = {
tv_sec: (long int) sec,
tv_nsec: 0
};
- nanosleep(&ts, &ts);
- return(sec-ts.tv_sec);
+ res = nanosleep(&ts, &ts);
+ if (res) res = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
+ return res;
}
#else