On Wed, Jan 31, 2018 at 07:25:58AM +0000, Jason McIntyre wrote:
> On Wed, Jan 31, 2018 at 05:52:35AM +0100, Theo Buehler wrote:
> > On Thu, Jan 25, 2018 at 09:35:33PM -0600, Scott Cheloha wrote:
> > > [...]
> > >
> > > I'm not sure whether the larger range is actually an extension to the
> > > standard, and if so whether we need to mention it in the manpage, but
> > > I've included a diff here anyway just in case. If you have ideas about
> > > the wording I'd love to hear them.
> > >
> > > Thoughts? ok?
> >
> > The diff for sleep.c is ok.
> >
> > For the manpage part, I have no strong opinion, but I'm not so sure this
> > is needed/useful. That sleeping for fractions of a second isn't portable
> > definitely has practical relevance, sleeping longer than 68 years not so
> > much. I'll leave this for jmc to decide.
>
> i tend to agree that it's not worth documenting, unless you have a
> concrete reason to do so.
... definitely not worth mentioning then.
Additional oks for just the sleep.c portion?
--
Scott Cheloha
Index: bin/sleep/sleep.c
===================================================================
RCS file: /cvs/src/bin/sleep/sleep.c,v
retrieving revision 1.24
diff -u -p -r1.24 sleep.c
--- bin/sleep/sleep.c 11 Oct 2015 20:17:49 -0000 1.24
+++ bin/sleep/sleep.c 1 Feb 2018 17:39:57 -0000
@@ -102,12 +102,24 @@ main(int argc, char *argv[])
}
}
- rqtp.tv_sec = secs;
- rqtp.tv_nsec = nsecs;
-
- if ((secs > 0) || (nsecs > 0))
+ 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))
err(1, NULL);
+ secs -= rqtp.tv_sec;
+ nsecs -= rqtp.tv_nsec;
+ }
return (0);
}