summaryrefslogtreecommitdiff
path: root/bin/sleep
AgeCommit message (Collapse)Author
2023-02-19sleep(1): minor markup tweaksuwe
2019-03-10Deal with overflow when the sleep duration given is a simplekre
integer (previously it was just clamped at the max possible value). This would have caused sleep 10000000000000000000 (or anything bigger) to have only actually slept for 9223372036854775807 secs. Someone would have noticed that happen, one day, in some other universe. This is now an error, as it was previously if this had been entered as sleep 1e19 Also detect an attempt to sleep for so long that a time_t will no longer be able to represent the current time when the sleep is done. Undo the attempts to work around a broken kernel nanosleep() implementation (by only ever issuing shortish sleep requests, and looping). That code was broken (idiot botch of mine) though you would have had to wait a month to observe it happen. I was going to just fix it, but sanity prevailed, and the kernel got fixed instead. That allows this to be much simplified, only looping as needed to handle dealing with SIGINFO. Switch to using clock_nanosleep() to implement the delay, as while our nanosleep() uses CLOCK_MONOTONIC the standards say it should use CLOCK_REALTIME, and if that we ever changed that, the old way would alter "sleep 5" from "sleep for 5 seconds" to "sleep until now + 5 secs", which is subtly different. Always use %g format to print the original sleep duration in reports of how much time remains - this works best for both long and short durations. A couple of other minor (frill) mods to the SIGINFO report message as well.
2019-01-27Sort sections.wiz
2019-01-27cast to intmax_t instead of long, since time_t is "long long"christos
2019-01-26Explicitly cast time_t to match format string - should fix the build onmartin
some 32bit architectures.
2019-01-26While cute, the previous version is not really safe.kre
After all, a system might want to sleep for several thousand years on a spaceship headed to a distant solar system... So, remove the pause() code, deal with limits on the range (it is just an int) that can be passed to sleep() by looping, and do a much better job of checking for out of range input values. With this change sleep(1) should work for durations up to something more than 250 billion years. It fails (at startup, with an error) if the requested duration is beyond what can be handled. Here no changes at all related to locales and arg parsing. Still for another day.
2019-01-26Adjust the way the arg string is parsed in the "not entirelykre
integer" case, so we avoid adjusting the locale of sleep, and generally be more reliable and simpler. In addition, deal with weirdness in nanosleep() when the interval gets long, by avoiding using it. In this version when the sleep interval < 10000 seconds, we use nanosleep() as before, for delays longer than that we use sleep() instead, and ignore any fractional seconds. We avoid overflow problems here by not bothering to sleep at all for delays longer than 135 years (approx) and simply pause() instead. That sleep never terminates in such a case is unlikely to ever be observed. This commit makes no decision on the question of whether the arg should be interpreted in the locale of the user, or always in the C locale. That is for another day.
2019-01-19Allow the decimal radix character '.' to work, regardless ofkre
what the current locale's radix character happens to be, while still allowing locale specific entry of fractional seconds (ie: if you're in locale where the radix character is ',' you san use "sleep 2.5" or "sleep 2,5" and they accomplish the same thing). This avoids issues with the "sleep 0.05" in rc.subr which generated usage messages when a locale that does not use '.' as its radix character was in use. Reported on netbsd-users by Dima Veselov, with the problem diagnosed by Martin Husemann While here, tighten the arg validity checking (3+4 is no longer permitted as a synonym of 3) and allow 0.0 to mean the same thing as 0 rather than being an error. Also, make the SIGINFO reports a little nicer (IMO). The ATF tests for sleep all pass (not that that means a lot).
2017-07-03Remove workaround for ancient HTML generation code.wiz
2016-08-12Document the version sleep first appeared.sevan
Bump date.
2011-08-29Use __deadjoerg
2011-08-15Improve wording.wiz
From Snader_LB.
2010-10-09Bump date for SIGINFO.wiz
2010-10-09add SIGINFO support; from freebsd:mrg
when a SIGINFO is delivered, display the approximate remaining seconds.
2008-07-20Remove the \n and tabs from the __COPYRIGHT() strings.lukem
2007-08-18- Cleanup for sleep.c:hubertf
+ mark two functions as static + remove case '?' in switch() before default + use return instead of exit() in main() function + use constants EXIT_SUCCESS/EXIT_FAILURE instead of 0/1 - In man sleep(1): + cleanup example Patch submitted by Slava Semushin <php-coder@altlinux.ru> in private email.
2005-10-17PR/27140: "sleep time" doesn't error out.elad
Apply fix from Dheeraj Reddy.
2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc
Patches provided by Joel Baker in PR 22249, verified by myself.
2002-11-21Use shell glob expansion in the csh example, instead of ls with glob.kim
Reported by Jerry Peek <jpeek@jpeek.com>.
2002-09-25New policy: New sentences start on a new line.wiz
Patches by Robert Elz <kre at munnari oz au>, with minimal changes by me.
2002-02-08Generate <>& symbolically. I'm avoiding .../dist/... directories for now.ross
2001-12-20Sort SEE ALSO.wiz
2001-11-12PR/14558: Tero Kivinen: Check the return value of nanosleep and don't failchristos
silently.
2001-09-16ANSIfy and KNF by Petri Koistinen.wiz
2000-09-04For commands and utilities, use EXIT STATUS rather than RETURN VALUES askleink
appropriate (and documented in mdoc(7)).
2000-08-28Add 'RETURN VALUE' section header.hubertf
1998-11-04char -> unsigned charchristos
1998-07-28Be more retentive about use of NOTREACHED and noreturn.mycroft
1998-07-28Delint.mycroft
1998-04-09remove #include <sys/time.h> ; the include file bug noted in the comment ↵fair
above it has been fixed.
1997-11-05lintcgd
1997-09-14- getopt returns -1 not EOFlukem
- use .Nm appropriately
1997-08-04Make sleep handle non-integer values. Document the same, noting thatperry
the extension is grotesquely non-portable. As requested by Denny Gentry in pr-3914. He supplied some code, but I used all my own code in the change, and wrote documentation for the man page. This is creeping featurism at its worst. I added it only because I can't see a good reason for refusing. However, I'm disgusted with myself for doing it anyway.
1997-07-20Remove WARNS=1 from all the subdirectory Makefiles, and add it to Makefile.incchristos
now that all /bin has been cleaned.
1997-07-20Fix compiler warnings.christos
Add WARNS=1
1995-07-25Use "utility" instead of "command". Modern definitions of these termsjtc
are distinct (See POSIX.2 glossary). A utility is a executable, script or shell builtin; while a command can be any of those things plus lists, pipelines, compound commands (if, for, while) and shell function definitions.
1995-03-21convert to new RCS id conventions.cgd
1994-09-22Merge 4.4-Lite version.mycroft
1994-01-11Fix spelling errors.jtc
1993-12-31localization & manpage update.jtc
1993-09-10Quiet compiler warnings by explicitly declaring return value of main().jtc
1993-08-01Add RCS identifiers.mycroft
1993-08-01Add RCS indentifiers.mycroft
1993-08-01Add RCS identifiers.mycroft
1993-03-23changed "Id" to "Header" for rcsidscgd
1993-03-22added rcs ids to all filescgd
1993-03-21initial import of 386bsd-0.1 sourcescgd