1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH PTHREAD_TRYJOIN_NP 3 2021-08-27 "Linux man-pages (unreleased)"
8 pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
12 .RI ( libpthread ", " \-lpthread )
15 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
16 .B #include <pthread.h>
18 .BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
19 .BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
20 .BI " const struct timespec *" abstime );
23 These functions operate in the same way as
25 except for the differences described on this page.
28 .BR pthread_tryjoin_np ()
29 function performs a nonblocking join with the thread
31 returning the exit status of the thread in
35 has not yet terminated, then instead of blocking, as is done by
37 the call returns an error.
40 .BR pthread_timedjoin_np ()
41 function performs a join-with-timeout.
44 has not yet terminated,
45 then the call blocks until a maximum time, specified in
50 If the timeout expires before
53 the call returns an error.
59 specifying an absolute time measured since the Epoch (see
63 these functions return 0;
64 on error, they return an error number.
66 These functions can fail with the same errors as
68 .BR pthread_tryjoin_np ()
69 can in addition fail with the following error:
73 had not yet terminated at the time of the call.
75 .BR pthread_timedjoin_np ()
76 can in addition fail with the following errors:
87 The call timed out before
91 .BR pthread_timedjoin_np ()
92 never returns the error
95 These functions first appeared in glibc in version 2.3.3.
97 For an explanation of the terms used in this section, see
105 Interface Attribute Value
107 .BR pthread_tryjoin_np (),
108 .BR pthread_timedjoin_np ()
109 T} Thread safety MT-Safe
115 These functions are nonstandard GNU extensions;
116 hence the suffix "_np" (nonportable) in the names.
119 .BR pthread_timedjoin_np ()
120 function measures time by internally calculating a relative sleep interval
121 that is then measured against the
126 Consequently, the timeout is unaffected by discontinuous changes to the
130 The following code waits to join for up to 5 seconds:
139 if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
145 s = pthread_timedjoin_np(thread, NULL, &ts);
152 .BR clock_gettime (2),
153 .BR pthread_exit (3),
154 .BR pthread_join (3),