Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

usleep - suspend process for defined interval

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

int usleep(useconds_t useconds);

Description  Suspends the current process for useconds microseconds. The actual length of time for

which the process is suspended can be longer than useconds microseconds due to other
activities in the system or because of the time required for processing the call.

useconds must be < 1 000 000. If useconds = 0, then usleep() has no effect.

The routine is implemented by setting the interval timer of the process and then waiting until
it expires. The previous status of the timer is saved and restored. If the wait time or ’sleep
time’ exceeds the period until expiry of the previous timer, the process is only suspended
until the signal would have occurred, and the signal is sent shortly before this sleep time
expires.

If threads are used, then the function affects the process or a thread in the following
manner: usleep() causes the current thread to be suspended until a specified time expires
or a signal is sent to the thread.

Return val.

0

-1

if successful.

otherwise.

Notes

See also

usleep() is supported for historical reasons. setitimer() should be used instead.

alarm(), getitimer(), sigaction(), sleep(), unistd.h.