]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Round more carefully so we never call nanosleep with more than 999,999,999
authorJim Meyering <jim@meyering.net>
Sun, 28 Nov 1999 14:03:43 +0000 (14:03 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 28 Nov 1999 14:03:43 +0000 (14:03 +0000)
nanoseconds.
Comment out assertion because it uses on EINTR.

src/sleep.c

index a5813dfde79a1cf4e1dc63ffacf5f996d0604536..4781f406dd85a66bb4792a5b7b13582fbdb57c0c 100644 (file)
@@ -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;