NAME
sleep
—
do nothing, slowly
SYNOPSIS
sleep |
[-- ]
delay[smhdwy]… |
DESCRIPTION
Sleep for the time(s) specified. Each delay is a floating-point amount of seconds, optionally suffixed with one of the following cumulative multipliers:
EXAMPLES
Wait a half-second:
sleep
0.5
sleep
1.388e-4h
Wait a year:
sleep
1y
sleep
3.1e+7
Wait infinitely, or until the heat death of the universe:
sleep
INF
sleep
10e+100y
SEE ALSO
STANDARDS
Conforms to IEEE Std 1003.1-2008 (“POSIX.1”), which only allows a single non-negative decimal integer delay. Multiple, floating-point delays and smhd suffixes are extensions, originating from the GNU system. wy suffixes are extensions.
HISTORY
sleep(II) ("delay execution") appeared in Version 2 AT&T UNIX:
NAME
sleep -- stop execution for interval
SYNOPSIS
(60ths of a second in r0)
sys sleep / sleep = 35.; not in assembler
Version 3 AT&T UNIX sleep(II) takes whole seconds, but the precision limitations remain.
Version 4 AT&T UNIX sees full-range sleep(II), and sleep(I) — "suspend execution for an interval", limited to 65536 (16 bits, unsigned, but it's more likely actually 32767, int) seconds (this is noted in the BUGS, despite being entirely expected with a 16-bit r0 on a 16-bit machine).
Version 7 AT&T UNIX replaces
sleep(II) with
ftime(2) and implements
sleep(3), based on
alarm(2),
pause(2), and
longjmp(3), in Standard C Library
(libc, -lc), but leaves sleep
unchanged.
Version 7 AT&T UNIX/32V just blindly updates the BUGS to say that the max is 2147483647 seconds. Considering this is now 68 years, rather than the 18ish hours (or, indeed, 9ish, as the case may be), this raises question about the fore-seen use-cases.
This sleep
implementation persists into
AT&T UNIX and the BSD
(but Version 3 AT&T UNIX and
4.2BSD cool it on the
longjmp(3)s in
sleep(3)), and is standardised verbatim in X/Open
Portability Guide Issue 2
(“XPG2”).