SLEEP(3C) SysV SLEEP(3C)
NAME
sleep - suspend execution for interval
SYNOPSIS
unsigned sleep (seconds)
unsigned seconds;
DESCRIPTION
The current process is suspended from execution for the number of seconds
specified by the argument. The actual suspension time may be less than
that requested for two reasons: (1) Because scheduled wakeups occur at
fixed 1-second intervals, (on the second, according to an internal clock)
and (2) because any caught signal will terminate the sleep following
execution of that signal's catching routine. Also, the suspension time
may be longer than requested by an arbitrary amount due to the scheduling
of other activity in the system. The value returned by sleep will be the
"unslept" amount (the requested time minus the time actually slept) in
case the caller had an alarm set to go off earlier than the end of the
requested sleep time, or premature arousal due to another caught signal.
The sleep function causes the current process to be suspended from
execution until either at least the specified number of real time seconds
specified by the argument seconds have elapsed or a signal is delivered
to the calling process and its action is to invoke a signal handling
function or to terminate the process. The suspension time may be longer
than requested due to the scheduling of other activity in the system.
DIAGNOSTICS
If the sleep() function returns because the requested time has elapsed, 0
(zero) is returned. If the sleep() function returns because a signal was
caught, the amount of time still remaining to be "slept" is returned.
SEE ALSO
alarm(2), pause(2), signal(2).