DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

usleep(S)


usleep -- suspend process for interval in microseconds

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; the previous state of this timer is saved and restored. 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 original timer was set to expire and the signal is sent a short time later.

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 useconds argument specified 1,000,000 or more microseconds.

Usage

This routine is implemented using setitimer and requires eight system calls each time it is invoked.

Compatibility

The usleep function is included for its historical usage. The setitimer function is preferred over this function. See getitimer(S).

References

alarm(S), getitimer(S), sigaction(S), signal(S), sleep(S), usleep(S)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005