suspend execution for an interval of
function suspends execution of the calling thread until at least the given
number of seconds have elapsed or an unmasked signal
is delivered to the calling thread.
This version of
implemented with nanosleep(2), so delivery of any unmasked signal will
terminate the sleep early, even if
SA_RESTART is set
with sigaction(2) for the interrupting signal.
sleep() sleeps for the full count of
seconds, it returns 0. Otherwise,
sleep() returns the number of seconds remaining from
the original request.
sleep() function sets
EINTR if it is
interrupted by the delivery of a signal.
sleep(1), nanosleep(2), sigaction(2)
sleep() function conforms to
IEEE Std 1003.1-2008 (“POSIX.1”).
Setting errno is an extension to that specification.
sleep() system call first appeared in
Version 2 AT&T UNIX. In
Version 7 AT&T UNIX, it was removed and
replaced by a C library implementation based on
and alarm(3). For OpenBSD 2.1, it was
reimplemented as a wrapper around the
nanosleep(2) system call.