usleep(2)
NAME
usleep − suspend execution for an interval
SYNOPSIS
#include <unistd.h>
int usleep(useconds_t useconds);
DESCRIPTION
The usleep() function suspends the current process from execution for the number of microseconds specified by the useconds argument. 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.
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 uses the process’ real-time 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 process will be woken up shortly before the timer was set to expire.
Implementations may place limitations on the granularity of timer values. For each interval timer, if the requested timer value requires a finer granularity than the implementation supports, the actual timer value will be rounded up to the next supported value.
Interactions between usleep() and either alarm() or sleep() are unspecified.
RETURN VALUE
On successful completion, usleep() returns 0. Otherwise, it returns −1 and sets errno to indicate the error.
ERRORS
The usleep() function may fail if:
[EINVAL] The time interval specified 1,000,000 or more microseconds.
APPLICATION USAGE
The usleep() function is included for its historical usage. The setitimer() function is preferred over this function.
SEE ALSO
alarm(), getitimer(), sigaction(), sleep(), <unistd.h>.
CHANGE HISTORY
First released in Issue 4, Version 2.
Hewlett-Packard Company — HP-UX Release 10.20: July 1996