sleep(3C)
NAME
sleep - suspend execution for an interval of time
SYNOPSIS
#include <unistd.h>
unsigned int sleep(unsigned int 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 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 because
of 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 because of
another caught signal.
In a single-threaded program (one not linked with -lthread
or -lpthread), the routine is implemented by setting an
alarm signal and pausing until it (or some other signal)
occurs. The previous state of the alarm signal is saved and
restored. The calling program may have set up an alarm sig-
nal before calling sleep(). If the sleep() time exceeds the
time until such alarm signal, the process sleeps only until
the alarm signal would have occurred. The caller's alarm
catch routine is executed just before the sleep() routine
returns. But if the sleep() time is less than the time till
such alarm, the prior alarm time is reset to go off at the
same time it would have without the intervening sleep().
In a multithreaded program (one linked with -lthread or
-lpthread), the routine is implemented with a call to the
nanosleep(3RT) function and does not modify the state of the
alarm signal.
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| MT-Level | Safe |
|_____________________________|_____________________________|
SEE ALSO
alarm(2), pause(2), signal(3C), attributes(5)
NOTES
In a single-threaded program, the SIGALRM signal should not
be blocked or ignored during a call to sleep(). This res-
triction does not apply to a multithreaded program.
In a multithreaded program, only the invoking thread is
suspended from execution.
Man(1) output converted with
man2html