pthread_tryjoin_np(3) Library Functions Manual pthread_tryjoin_np(3) pthread_tryjoin_np, pthread_timedjoin_np - POSIX threads library (libpthread, -lpthread) #define _GNU_SOURCE /* feature_test_macros(7) */ #include int pthread_tryjoin_np(pthread_t thread, void **retval); int pthread_timedjoin_np(pthread_t thread, void **retval, const struct timespec *abstime); pthread_join(3) , . pthread_tryjoin_np() thread, *retval . thread , , pthread_join(3), . The pthread_timedjoin_np() function performs a join-with-timeout. If thread has not yet terminated, then the call blocks until a maximum time, specified in abstime, measured against the CLOCK_REALTIME clock. If the timeout expires before thread terminates, the call returns an error. The abstime argument is a timespec(3) structure, specifying an absolute time measured since the Epoch (see time(2)). 0; . pthread_join(3). , pthread_tryjoin_np() : EBUSY thread . , pthread_timedjoin_np() : EINVAL abstime (tv_sec 0 tv_nsec 1e9). ETIMEDOUT thread. pthread_timedjoin_np() EINTR. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |pthread_tryjoin_np(), | | MT-Safe | |pthread_timedjoin_np() | | | +----------------------------+----------------------------------------------------------+--------------------------+ GNU, <<_np>> (nonportable) . glibc 2.3.3. The pthread_timedjoin_np() function measures time by internally calculating a relative sleep interval that is then measured against the CLOCK_MONOTONIC clock instead of the CLOCK_REALTIME clock. Consequently, the timeout is unaffected by discontinuous changes to the CLOCK_REALTIME clock. 5 : struct timespec ts; int s; ... if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { /* Handle error */ } ts.tv_sec += 5; s = pthread_timedjoin_np(thread, NULL, &ts); if (s != 0) { /* Handle error */ } clock_gettime(2), pthread_exit(3), pthread_join(3), timespec(3), pthreads(7) () Alexey, Azamat Hackimov , kogamatranslator49 , Darima Kogan , Max Is , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . pthread_tryjoin_np(3)