NAME
sleep
—
suspend execution for an interval of
seconds
SYNOPSIS
#include
<unistd.h>
unsigned int
sleep
(unsigned
int seconds);
DESCRIPTION
The
sleep
()
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
sleep
() is
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.
RETURN VALUES
If sleep
() sleeps for the full count of
seconds, it returns 0. Otherwise,
sleep
() returns the number of seconds remaining from
the original request.
ERRORS
The sleep
() function sets
errno to EINTR
if it is
interrupted by the delivery of a signal.
SEE ALSO
STANDARDS
The sleep
() function conforms to
IEEE Std 1003.1-2008 (“POSIX.1”).
Setting errno is an extension to that specification.
HISTORY
A 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
signal(3) and
alarm(3). For OpenBSD 2.1, it was
reimplemented as a wrapper around the
nanosleep(2) system call.