#include <unistd.h>int usleep(useconds_t useconds);
The usleep() function suspends the caller from execution for the number of microseconds specified by the useconds argument. (A microsecond is .000001 seconds.) Because of other activity, or because of the time spent in processing the call, the actual suspension time may be longer than the amount of time specified.
If the value of useconds is 0, then the call has no effect.
In a single-threaded program (one not linked with -lthread or -lpthread), the usleep() function uses the process's realtime interval timer to indicate to the system when the process should be woken up.
There is one real-time interval timer for each process. The usleep() function will not interfere with a previous setting of this timer. If the process has set this timer prior to calling usleep(), and if the time specified by useconds equals or exceeds the interval timer's prior setting, the caller will be woken up shortly before the timer was set to expire.
In a multithreaded program (one linked with -lthread or -lpthread), usleep() is implemented by a call to nanosleep(3RT) and does not modify the state of the alarm signal or the realtime interval timer. There is no interaction between this version of usleep() and either alarm(2) or sleep(3C).
On completion, usleep() returns 0. There are no error retruns.
No errors are returned.
The usleep() function is included for its historical usage. The nanosleep(3RT) function is preferred over this function.
See attributes(5) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
In a multithreaded program, only the invoking thread is suspended from execution.