1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH PTHREAD_TRYJOIN_NP 3 2021-03-22 "Linux" "Linux Programmer's Manual"
28 pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
32 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
33 .B #include <pthread.h>
35 .BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
36 .BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
37 .BI " const struct timespec *" abstime );
40 Compile and link with \fI\-pthread\fP.
42 These functions operate in the same way as
44 except for the differences described on this page.
47 .BR pthread_tryjoin_np ()
48 function performs a nonblocking join with the thread
50 returning the exit status of the thread in
54 has not yet terminated, then instead of blocking, as is done by
56 the call returns an error.
59 .BR pthread_timedjoin_np ()
60 function performs a join-with-timeout.
63 has not yet terminated,
64 then the call blocks until a maximum time, specified in
69 If the timeout expires before
72 the call returns an error.
75 argument is a structure of the following form,
76 specifying an absolute time measured since the Epoch (see
82 time_t tv_sec; /* seconds */
83 long tv_nsec; /* nanoseconds */
89 these functions return 0;
90 on error, they return an error number.
92 These functions can fail with the same errors as
94 .BR pthread_tryjoin_np ()
95 can in addition fail with the following error:
99 had not yet terminated at the time of the call.
101 .BR pthread_timedjoin_np ()
102 can in addition fail with the following errors:
105 The call timed out before
115 is greater than 1e9).
117 .BR pthread_timedjoin_np ()
118 never returns the error
121 These functions first appeared in glibc in version 2.3.3.
123 For an explanation of the terms used in this section, see
131 Interface Attribute Value
133 .BR pthread_tryjoin_np (),
134 .BR pthread_timedjoin_np ()
135 T} Thread safety MT-Safe
141 These functions are nonstandard GNU extensions;
142 hence the suffix "_np" (nonportable) in the names.
144 The following code waits to join for up to 5 seconds:
153 if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
159 s = pthread_timedjoin_np(thread, NULL, &ts);
167 .BR pthread_timedjoin_np ()
168 function measures time by internally calculating a relative sleep interval
169 that is then measured against the
174 Consequently, the timeout is unaffected by discontinuous changes to the
178 .BR clock_gettime (2),
179 .BR pthread_exit (3),
180 .BR pthread_join (3),