summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-11-28 14:03:43 +0000
committerJim Meyering <jim@meyering.net>1999-11-28 14:03:43 +0000
commite20a9b89d297248929c88ce749f334e44f0d6ac5 (patch)
tree9c64d299f0b2578c29690d54e72e613ae9556ac2 /src
parent0baa5231545cf3a6e6b0697e12e2fe544fd2e04a (diff)
downloadcoreutils-e20a9b89d297248929c88ce749f334e44f0d6ac5.tar.xz
Round more carefully so we never call nanosleep with more than 999,999,999
nanoseconds. Comment out assertion because it uses on EINTR.
Diffstat (limited to 'src')
-rw-r--r--src/sleep.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/sleep.c b/src/sleep.c
index a5813dfde..4781f406d 100644
--- a/src/sleep.c
+++ b/src/sleep.c
@@ -168,14 +168,19 @@ main (int argc, char **argv)
if (fail)
usage (1);
+ /* Round to the nearest nanosecond here so that tv_nsec will be
+ no larger than 999,999,999. */
+ seconds += .0000000005;
+
+ /* Separate whole seconds from nanoseconds. */
ts.tv_sec = seconds;
- ts.tv_nsec = (int) ((seconds - ts.tv_sec) * 1000000000 + .5);
+ ts.tv_nsec = (seconds - ts.tv_sec) * 1000000000;
while (1)
{
struct timespec remaining;
interrupted = nanosleep (&ts, &remaining);
- assert (!interrupted || errno == EINTR);
+ /* assert (!interrupted || errno == EINTR); */
if (!interrupted)
break;
ts = remaining;