NANOSLEEP(2) Linux Programmer's Manual NANOSLEEP(2) NAME nanosleep - high-resolution sleep SYNOPSIS #include int nanosleep(const struct timespec *req, struct timespec *rem); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): nanosleep(): _POSIX_C_SOURCE >= 199309L DESCRIPTION nanosleep() suspends the execution of the calling thread until either at least the time specified in *req has elapsed, or the delivery of a signal that triggers the invocation of a handler in the calling thread or that terminates the process. If the call is interrupted by a signal handler, nanosleep() returns -1, sets errno to EINTR, and writes the remaining time into the structure pointed to by rem unless rem is NULL. The value of *rem can then be used to call nanosleep() again and complete the specified pause (but see NOTES). The structure timespec is used to specify intervals of time with nanosecond precision. It is defined as follows: struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; The value of the nanoseconds field must be in the range 0 to 999999999. Compared to sleep(3) and usleep(3), nanosleep() has the following ad‐ Manual page nanosleep(2) line 1 (press h for help or q to quit)