usleep() — Suspend execution for an interval
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both | POSIX(ON) |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
int usleep(useconds_t useconds);
General description
The usleep() function suspends thread execution for the number of microseconds specified by the useconds argument. Because of other activity, or because of the time spent processing the call, the actual suspension time may be longer than the amount of time specified.
The useconds argument must be less than 1,000,000. If the value of useconds is 0, then the call has no effect.
The usleep() function will not interfere with a previous setting of the real-time interval timer. If the thread has set this timer before calling usleep(), and if the time specified by useconds equals or exceeds the interval timer's prior setting, then the thread will be awakened when the previously set timer interval expires.
Returned value
If successful, usleep() returns 0.
- Error Code
- Description
- EINVAL
- The useconds argument was greater than or equal to 1,000,000.