#
cb511420 |
| 10-Mar-2019 |
kre <kre@NetBSD.org> |
Deal with overflow when the sleep duration given is a simple integer (previously it was just clamped at the max possible value). This would have caused sleep 10000000000000000000 (or anything bigger
Deal with overflow when the sleep duration given is a simple 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.
show more ...
|
#
10dd4cc9 |
| 27-Jan-2019 |
christos <christos@NetBSD.org> |
cast to intmax_t instead of long, since time_t is "long long"
|
#
bfd96fcf |
| 26-Jan-2019 |
martin <martin@NetBSD.org> |
Explicitly cast time_t to match format string - should fix the build on some 32bit architectures.
|
#
763d688f |
| 26-Jan-2019 |
kre <kre@NetBSD.org> |
While cute, the previous version is not really safe. 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
While cute, the previous version is not really safe. 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.
show more ...
|
#
b95728b3 |
| 26-Jan-2019 |
kre <kre@NetBSD.org> |
Adjust the way the arg string is parsed in the "not entirely integer" case, so we avoid adjusting the locale of sleep, and generally be more reliable and simpler.
In addition, deal with weirdness in
Adjust the way the arg string is parsed in the "not entirely 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.
show more ...
|
#
e20c4e65 |
| 19-Jan-2019 |
kre <kre@NetBSD.org> |
Allow the decimal radix character '.' to work, regardless of what the current locale's radix character happens to be, while still allowing locale specific entry of fractional seconds (ie: if you're i
Allow the decimal radix character '.' to work, regardless of 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).
show more ...
|
#
007a7cf0 |
| 29-Aug-2011 |
joerg <joerg@NetBSD.org> |
Use __dead
|
#
3b4fa1d5 |
| 09-Oct-2010 |
mrg <mrg@NetBSD.org> |
add SIGINFO support; from freebsd:
when a SIGINFO is delivered, display the approximate remaining seconds.
|
#
2fe2731d |
| 20-Jul-2008 |
lukem <lukem@NetBSD.org> |
Remove the \n and tabs from the __COPYRIGHT() strings.
|
#
8e0c5879 |
| 18-Aug-2007 |
hubertf <hubertf@NetBSD.org> |
- Cleanup for sleep.c: + 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
- Cleanup for sleep.c: + 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.
show more ...
|
#
c9981d25 |
| 17-Oct-2005 |
elad <elad@NetBSD.org> |
PR/27140: "sleep time" doesn't error out. Apply fix from Dheeraj Reddy.
|
#
b5b29542 |
| 07-Aug-2003 |
agc <agc@NetBSD.org> |
Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
|
#
182abdd7 |
| 12-Nov-2001 |
christos <christos@NetBSD.org> |
PR/14558: Tero Kivinen: Check the return value of nanosleep and don't fail silently.
|
#
240b5f82 |
| 16-Sep-2001 |
wiz <wiz@NetBSD.org> |
ANSIfy and KNF by Petri Koistinen.
|
#
9908eacf |
| 04-Nov-1998 |
christos <christos@NetBSD.org> |
char -> unsigned char
|
#
ee9e50ea |
| 28-Jul-1998 |
mycroft <mycroft@NetBSD.org> |
Be more retentive about use of NOTREACHED and noreturn.
|
#
9dc385be |
| 28-Jul-1998 |
mycroft <mycroft@NetBSD.org> |
Delint.
|
#
927362e9 |
| 09-Apr-1998 |
fair <fair@NetBSD.org> |
remove #include <sys/time.h> ; the include file bug noted in the comment above it has been fixed.
|
#
bad15fd3 |
| 05-Nov-1997 |
cgd <cgd@NetBSD.org> |
lint
|
#
a9737b10 |
| 14-Sep-1997 |
lukem <lukem@NetBSD.org> |
- getopt returns -1 not EOF - use .Nm appropriately
|
#
ba29cbc5 |
| 04-Aug-1997 |
perry <perry@NetBSD.org> |
Make sleep handle non-integer values. Document the same, noting that the extension is grotesquely non-portable.
As requested by Denny Gentry in pr-3914. He supplied some code, but I used all my own
Make sleep handle non-integer values. Document the same, noting that 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.
show more ...
|
#
e028842e |
| 20-Jul-1997 |
christos <christos@NetBSD.org> |
Fix compiler warnings. Add WARNS=1
|
#
49f0ad86 |
| 21-Mar-1995 |
cgd <cgd@NetBSD.org> |
convert to new RCS id conventions.
|
#
667b5ea1 |
| 22-Sep-1994 |
mycroft <mycroft@NetBSD.org> |
Merge 4.4-Lite version.
|
#
88dd434d |
| 31-Dec-1993 |
jtc <jtc@NetBSD.org> |
localization & manpage update.
|