Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

nanosleep - suspend current thread

&pagelevel(4)&pagelevel

Syntax

#include <time.h>

int nanosleep(const struct timespec * rqtp, struct timespec * rmtp);

Description

rqtp expires or until a signal is sent to the calling thread that results in the calling of a signal handling routine or the termination of the process. The time in suspension may be longer than the time specified because the value was rounded up to be many times greater than the sleep resolution or because the system still needs to carry out other activities.

Return val.

0

if the specified time expires.


- 1

if nanosleep() was interrupted by a signal. If rmtp is not a null pointer, the time remaining will be stored in this case in the structure pointed to by rmtp.
If rmtp is NULL, the time remaining is not returned.

errno is set to indicate an error.

Errors

nanosleep() fails if:

 

EINTR

nanosleep() was interrupted by a signal.

 

EINVAL

A value was specified in nanoseconds that is less than 0 or greater than or equal to 1000 million in the rqtp argument.

 

ENOSYS

The function nanosleep() is not supported in this implementation.

See also

sleep(), time.h.