clock_nanosleep(2) System Calls Manual clock_nanosleep(2) clock_nanosleep - Standard C library (libc, -lc), since glibc 2.17 Before glibc 2.17, Real-time library (librt, -lrt) #include int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *t, struct timespec *_Nullable remain); glibc (. feature_test_macros(7)): clock_nanosleep(): _POSIX_C_SOURCE >= 200112L nanosleep(2), clock_nanosleep() . , , , . , , timespec(3). clockid , . : CLOCK_REALTIME . CLOCK_TAI ( Linux 3.10) , , . CLOCK_MONOTONIC , , , . CLOCK_BOOTTIME ( Linux 2.6.39) CLOCK_MONOTONIC, , , . CLOCK_PROCESS_CPUTIME_ID , , . clock_getres(2). ID , clock_getcpuclockid(3) pthread_getcpuclockid(3), clockid. If flags is 0, then the value specified in t is interpreted as an interval relative to the current value of the clock specified by clockid. If flags is TIMER_ABSTIME, then t is interpreted as an absolute time as measured by the clock, clockid. If t is less than or equal to the current value of the clock, then clock_nanosleep() returns immediately without suspending the calling thread. clock_nanosleep() suspends the execution of the calling thread until either at least the time specified by t has elapsed, or a signal is delivered that causes a signal handler to be called or that terminates the process. , clock_nanosleep() EINTR. , remain NULL flags TIMER_ABSTIME, remain . clock_nanosleep() () . , clock_nanosleep() 0. , , . EFAULT t remain . EINTR ; signal(7). EINVAL tv_nsec [0, 999999999] tv_nsec . EINVAL clockid. ( CLOCK_THREAD_CPUTIME_ID clockid.) ENOTSUP clockid. POSIX.1-2024. POSIX.1-2001. Linux 2.6, glibc 2.1. If the interval specified in t is not an exact multiple of the granularity underlying clock (see time(7)), then the interval will be rounded up to the next multiple. Furthermore, after the sleep completes, there may still be a delay before the CPU becomes free to once again execute the calling thread. , nanosleep(2). ( , .) , clock_gettime(2) , clock_nanosleep() TIMER_ABSTIME. clock_nanosleep() , , SA_RESTART sigaction(2). The remain argument is unused, and unnecessary, when flags is TIMER_ABSTIME. (An absolute sleep can be restarted using the same t argument.) POSIX.1 , clock_nanosleep() . POSIX.1 , CLOCK_REALTIME clock_settime(2), , clock_nanosleep() ; , clock_nanosleep() . POSIX.1 , CLOCK_REALTIME clock_settime(2) , clock_nanosleep() . clock_getres(2), nanosleep(2), restart_syscall(2), timer_create(2), sleep(3), timespec(3), usleep(3), time(7) () Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 29 2025 . clock_nanosleep(2)