]> git.ipfire.org Git - thirdparty/man-pages.git/blame_incremental - man3/pthread_tryjoin_np.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / pthread_tryjoin_np.3
... / ...
CommitLineData
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
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.
8.\"
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.
13.\"
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
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\" %%%LICENSE_END
25.\"
26.TH PTHREAD_TRYJOIN_NP 3 2017-09-15 "Linux" "Linux Programmer's Manual"
27.SH NAME
28pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
29terminated thread
30.SH SYNOPSIS
31.nf
32.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
33.B #include <pthread.h>
34.PP
35.BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
36.PP
37.BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
38.BI " const struct timespec *" abstime );
39.fi
40.PP
41Compile and link with \fI\-pthread\fP.
42.SH DESCRIPTION
43These functions operate in the same way as
44.BR pthread_join (3),
45except for the differences described on this page.
46.PP
47The
48.BR pthread_tryjoin_np ()
49function performs a nonblocking join with the thread
50.IR thread ,
51returning the exit status of the thread in
52.IR *retval .
53If
54.I thread
55has not yet terminated, then instead of blocking, as is done by
56.BR pthread_join (3),
57the call returns an error.
58.PP
59The
60.BR pthread_timedjoin_np ()
61function performs a join-with-timeout.
62If
63.I thread
64has not yet terminated,
65then the call blocks until a maximum time, specified in
66.IR abstime .
67If the timeout expires before
68.I thread
69terminates,
70the call returns an error.
71The
72.I abstime
73argument is a structure of the following form,
74specifying an absolute time measured since the Epoch (see
75.BR time (2)):
76.PP
77.in +4n
78.EX
79struct timespec {
80 time_t tv_sec; /* seconds */
81 long tv_nsec; /* nanoseconds */
82};
83.EE
84.in
85.SH RETURN VALUE
86On success,
87these functions return 0;
88on error, they return an error number.
89.SH ERRORS
90These functions can fail with the same errors as
91.BR pthread_join (3).
92.BR pthread_tryjoin_np ()
93can in addition fail with the following error:
94.TP
95.B EBUSY
96.I thread
97had not yet terminated at the time of the call.
98.PP
99.BR pthread_timedjoin_np ()
100can in addition fail with the following errors:
101.TP
102.BR ETIMEDOUT
103The call timed out before
104.I thread
105terminated.
106.TP
107.BR EINVAL
108.I abstime
109value is invalid
110.RI ( tv_sec
111is less than 0 or
112.IR tv_nsec
113is greater than 1e9).
114.PP
115.BR pthread_timedjoin_np ()
116never returns the error
117.BR EINTR .
118.SH VERSIONS
119These functions first appeared in glibc in version 2.3.3.
120.SH ATTRIBUTES
121For an explanation of the terms used in this section, see
122.BR attributes (7).
123.ad l
124.TS
125allbox;
126lbw22 lb lb
127l l l.
128Interface Attribute Value
129T{
130.BR pthread_tryjoin_np (),
131.BR pthread_timedjoin_np ()
132T} Thread safety MT-Safe
133.TE
134.ad
135.SH CONFORMING TO
136These functions are nonstandard GNU extensions;
137hence the suffix "_np" (nonportable) in the names.
138.SH EXAMPLE
139The following code waits to join for up to 5 seconds:
140.PP
141.in +4n
142.EX
143struct timespec ts;
144int s;
145
146\&...
147
148if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
149 /* Handle error */
150}
151
152ts.tv_sec += 5;
153
154s = pthread_timedjoin_np(thread, NULL, &ts);
155if (s != 0) {
156 /* Handle error */
157}
158.EE
159.in
160.SH SEE ALSO
161.BR clock_gettime (2),
162.BR pthread_exit (3),
163.BR pthread_join (3),
164.BR pthreads (7)