From 9f4c1fd2de1b525b7638a79a8294f8d5b865bcc5 Mon Sep 17 00:00:00 2001 From: Georgi Chorbadzhiyski Date: Sat, 10 Mar 2012 14:57:33 -0600 Subject: Fix nanosleep() usage. --- toys/sleep.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/sleep.c b/toys/sleep.c index 471011be..ed8523f3 100644 --- a/toys/sleep.c +++ b/toys/sleep.c @@ -49,7 +49,13 @@ void sleep_main(void) l = (unsigned long)d; d -= l; if (l) toys.exitval = sleep(l); - if (!toys.exitval) - toys.exitval = nanosleep((unsigned long)(d * 1000000000)); + if (!toys.exitval) { + unsigned long usec = d * 1000000; + struct timespec tv = { + .tv_sec = usec / 1000000, + .tv_nsec = (usec % 1000000) * 1000 + }; + toys.exitval = nanosleep(&tv, NULL); + } } } -- cgit v1.2.3