]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_tryjoin_np.3
getcpu.2, sendfile.2, cmsg.3, rtnetlink.3, arp.7, ddp.7, fifo.7, icmp.7, ip.7, ipv6...
[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.\"
4b72fb64 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.\"
86b91fdf 26.TH PTHREAD_TRYJOIN_NP 3 2010-09-10 "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 ()
100can in addition fail with the following error:
101.TP
102.BR ETIMEDOUT
103The call timed out before
104.I thread
105terminated.
106.PP
107.BR pthread_timedjoin_np ()
108never returns the error
109.BR EINTR .
110.SH VERSIONS
111These functions first appeared in glibc in version 2.3.3.
112.SH CONFORMING TO
c8f2dd47 113These functions are nonstandard GNU extensions;
d603cc27 114hence the suffix "_np" (nonportable) in the names.
681f0d67
MK
115.SH EXAMPLE
116The following code waits to join for up to 5 seconds:
117
118.nf
119 struct timespec ts;
120 int s;
121
122 ...
123
13466d98
MK
124 if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
125 /* Handle error */
126 }
681f0d67
MK
127
128 ts.tv_sec += 5;
129
130 s = pthread_timedjoin_np(thread, NULL, &ts);
131 if (s != 0) {
132 /* Handle error */
133 }
134.fi
135.SH SEE ALSO
0eb44391 136.BR clock_gettime (2),
681f0d67 137.BR pthread_exit (3),
3e5c319e 138.BR pthread_join (3),
681f0d67 139.BR pthreads (7)