]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_tryjoin_np.3
perf_event_open.2: srcfix
[thirdparty/man-pages.git] / man3 / pthread_tryjoin_np.3
CommitLineData
681f0d67
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
681f0d67
MK
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.
4b72fb64 24.\" %%%LICENSE_END
681f0d67 25.\"
5722c835 26.TH PTHREAD_TRYJOIN_NP 3 2015-07-23 "Linux" "Linux Programmer's Manual"
681f0d67
MK
27.SH NAME
28pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
29terminated thread
30.SH SYNOPSIS
31.nf
86b91fdf 32.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
681f0d67
MK
33.B #include <pthread.h>
34
35.BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
36
37.BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
5b4e617f 38.BI " const struct timespec *" abstime );
681f0d67
MK
39.fi
40.sp
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
47The
48.BR pthread_tryjoin_np ()
ff40dbb3 49function performs a nonblocking join with the thread
681f0d67
MK
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
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
77.in +4n
78.nf
79struct timespec {
80 time_t tv_sec; /* seconds */
81 long tv_nsec; /* nanoseconds */
82};
83.fi
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 ()
dc891cf9 100can in addition fail with the following errors:
681f0d67
MK
101.TP
102.BR ETIMEDOUT
103The call timed out before
104.I thread
105terminated.
e7e39a14
JP
106.TP
107.BR EINVAL
108.I abstime
305965f5
MK
109value is invalid
110.RI ( tv_sec
111is less than 0 or
112.IR tv_nsec
113is greater than 1e9).
681f0d67
MK
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.
672a9903
ZL
120.SH ATTRIBUTES
121For an explanation of the terms used in this section, see
122.BR attributes (7).
74714ea8 123.ad l
672a9903
ZL
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
74714ea8 134.ad
681f0d67 135.SH CONFORMING TO
c8f2dd47 136These functions are nonstandard GNU extensions;
d603cc27 137hence the suffix "_np" (nonportable) in the names.
681f0d67
MK
138.SH EXAMPLE
139The following code waits to join for up to 5 seconds:
140
141.nf
142 struct timespec ts;
143 int s;
144
145 ...
146
13466d98
MK
147 if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
148 /* Handle error */
149 }
681f0d67
MK
150
151 ts.tv_sec += 5;
152
153 s = pthread_timedjoin_np(thread, NULL, &ts);
154 if (s != 0) {
155 /* Handle error */
156 }
157.fi
158.SH SEE ALSO
0eb44391 159.BR clock_gettime (2),
681f0d67 160.BR pthread_exit (3),
3e5c319e 161.BR pthread_join (3),
681f0d67 162.BR pthreads (7)