nanosleep(2) System Calls Manual nanosleep(2) nanosleep - LIBRARY Standard C library (libc, -lc) #include int nanosleep(const struct timespec *req, struct timespec *_Nullable rem); glibc (. feature_test_macros(7)): nanosleep(): _POSIX_C_SOURCE >= 199309L nanosleep() , *req, , , . , nanosleep() -1, errno EINTR , rem, rem NULL. *rem nanosleep() ( . ). The timespec(3) structure is used to specify intervals of time with nanosecond precision. The value of the nanoseconds field must be in the range [0, 999999999]. sleep(3) usleep(3), nanosleep() : , POSIX.1 , , . nanosleep() . , -1, errno . EFAULT . EINTR , ( signal(7)). *rem , nanosleep() . EINVAL The value in the tv_nsec field was not in the range [0, 999999999] or tv_sec was negative. POSIX.1 , nanosleep() CLOCK_REALTIME. , Linux CLOCK_MONOTONIC. , , , POSIX.1 clock_settime(2) , CLOCK_REALTIME nanosleep(): CLOCK_REALTIME clock_settime(2) , - , , nanosleep(); ... , , , . POSIX.1-2008. POSIX.1-2001. In order to support applications requiring much more precise pauses (e.g., in order to control some time-critical hardware), nanosleep() would handle pauses of up to 2 milliseconds by busy waiting with microsecond precision when called from a thread scheduled under a real-time policy like SCHED_FIFO or SCHED_RR. This special extension was removed in Linux 2.5.39, and is thus not available in Linux 2.6.0 and later kernels. , req, (. time(7)), . , , . , nanosleep() , , , . , clock_nanosleep(2) . , nanosleep(), , , nanosleep(). clock_nanosleep(2) TIMER_ABSTIME, . Linux 2.4, nanosleep() (, SIGTSTP), , SIGCONT, EINTR. , , , . Linux 2.6.0 . . clock_nanosleep(2), restart_syscall(2), sched_setscheduler(2), timer_create(2), sleep(3), timespec(3), usleep(3), time(7) Alex Nik , Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . nanosleep(2)