aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorGeorgi Chorbadzhiyski <gf@unixsol.org>2012-03-10 14:57:33 -0600
committerGeorgi Chorbadzhiyski <gf@unixsol.org>2012-03-10 14:57:33 -0600
commit9f4c1fd2de1b525b7638a79a8294f8d5b865bcc5 (patch)
treeee6e3e2a2a1bf9ce09b8022c94073780d5f432ae /toys
parent28427d2fff6074f8be173b6dbb76cf05a41e0e3e (diff)
downloadtoybox-9f4c1fd2de1b525b7638a79a8294f8d5b865bcc5.tar.gz
Fix nanosleep() usage.
Diffstat (limited to 'toys')
-rw-r--r--toys/sleep.c10
1 files changed, 8 insertions, 2 deletions
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);
+ }
}
}