Now that we have removed the 100 million second upper bound we can
remove this awful loop.

Effectively a revert of sleep.c 1.25.

ok?

Index: sleep.c
===================================================================
RCS file: /cvs/src/bin/sleep/sleep.c,v
retrieving revision 1.26
diff -u -p -r1.26 sleep.c
--- sleep.c     4 Feb 2018 02:18:15 -0000       1.26
+++ sleep.c     10 Jan 2019 15:45:23 -0000
@@ -30,6 +30,8 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/time.h>
+
 #include <ctype.h>
 #include <signal.h>
 #include <stdio.h>
@@ -101,24 +103,14 @@ main(int argc, char *argv[])
                }
        }
 
-       while (secs > 0 || nsecs > 0) {
-               /*
-                * nanosleep(2) supports a maximum of 100 million
-                * seconds, so we break the nap up into multiple
-                * calls if we have more than that.
-                */
-               if (secs > 100000000) {
-                       rqtp.tv_sec = 100000000;
-                       rqtp.tv_nsec = 0;
-               } else {
-                       rqtp.tv_sec = secs;
-                       rqtp.tv_nsec = nsecs;
-               }
-               if (nanosleep(&rqtp, NULL))
+       rqtp.tv_sec = secs;
+       rqtp.tv_nsec = nsecs;
+
+       if (timespecisset(&rqtp)) {
+               if (nanosleep(&rqtp, NULL) == -1)
                        err(1, NULL);
-               secs -= rqtp.tv_sec;
-               nsecs -= rqtp.tv_nsec;
        }
+
        return (0);
 }
 

Reply via email to