Mercurial > hg > toybox
changeset 539:09135436042b
Fix nanosleep() usage.
author | Georgi Chorbadzhiyski <gf@unixsol.org> |
---|---|
date | Sat, 10 Mar 2012 14:57:33 -0600 |
parents | 9ab5ee341d47 |
children | c2f39708a4c4 |
files | toys/sleep.c |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/sleep.c Fri Mar 09 20:33:16 2012 -0600 +++ b/toys/sleep.c Sat Mar 10 14:57:33 2012 -0600 @@ -49,7 +49,13 @@ 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); + } } }