]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_tryjoin_np.3
Many pages: Fix style issues reported by `make lint-groff`
[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.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
681f0d67 5.\"
6e00b7a8 6.TH PTHREAD_TRYJOIN_NP 3 2021-08-27 "Linux" "Linux Programmer's Manual"
681f0d67
MK
7.SH NAME
8pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
9terminated thread
4b76034e
AC
10.SH LIBRARY
11POSIX threads library
8fc3b2cf 12.RI ( libpthread ", " \-lpthread )
681f0d67
MK
13.SH SYNOPSIS
14.nf
86b91fdf 15.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
681f0d67 16.B #include <pthread.h>
dbfe9c70 17.PP
681f0d67 18.BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
681f0d67 19.BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
5b4e617f 20.BI " const struct timespec *" abstime );
681f0d67 21.fi
681f0d67
MK
22.SH DESCRIPTION
23These functions operate in the same way as
24.BR pthread_join (3),
25except for the differences described on this page.
847e0d88 26.PP
681f0d67
MK
27The
28.BR pthread_tryjoin_np ()
ff40dbb3 29function performs a nonblocking join with the thread
681f0d67
MK
30.IR thread ,
31returning the exit status of the thread in
32.IR *retval .
33If
34.I thread
35has not yet terminated, then instead of blocking, as is done by
36.BR pthread_join (3),
37the call returns an error.
847e0d88 38.PP
681f0d67
MK
39The
40.BR pthread_timedjoin_np ()
41function performs a join-with-timeout.
42If
43.I thread
44has not yet terminated,
45then the call blocks until a maximum time, specified in
6c9fd46b
MK
46.IR abstime ,
47measured against the
1ae6b2c7 48.B CLOCK_REALTIME
6c9fd46b 49clock.
681f0d67
MK
50If the timeout expires before
51.I thread
52terminates,
53the call returns an error.
54The
55.I abstime
e97e048a 56argument is a
57.BR timespec (3)
58structure,
681f0d67 59specifying an absolute time measured since the Epoch (see
e97e048a 60.BR time (2)).
681f0d67
MK
61.SH RETURN VALUE
62On success,
63these functions return 0;
64on error, they return an error number.
65.SH ERRORS
66These functions can fail with the same errors as
67.BR pthread_join (3).
68.BR pthread_tryjoin_np ()
69can in addition fail with the following error:
70.TP
71.B EBUSY
72.I thread
73had not yet terminated at the time of the call.
74.PP
75.BR pthread_timedjoin_np ()
dc891cf9 76can in addition fail with the following errors:
681f0d67 77.TP
1ae6b2c7 78.B EINVAL
e7e39a14 79.I abstime
305965f5
MK
80value is invalid
81.RI ( tv_sec
82is less than 0 or
1ae6b2c7 83.I tv_nsec
305965f5 84is greater than 1e9).
97e2d8e6 85.TP
1ae6b2c7 86.B ETIMEDOUT
97e2d8e6
MK
87The call timed out before
88.I thread
89terminated.
681f0d67
MK
90.PP
91.BR pthread_timedjoin_np ()
92never returns the error
93.BR EINTR .
94.SH VERSIONS
95These functions first appeared in glibc in version 2.3.3.
672a9903
ZL
96.SH ATTRIBUTES
97For an explanation of the terms used in this section, see
98.BR attributes (7).
74714ea8 99.ad l
c466875e 100.nh
672a9903
ZL
101.TS
102allbox;
c466875e 103lbx lb lb
672a9903
ZL
104l l l.
105Interface Attribute Value
106T{
107.BR pthread_tryjoin_np (),
108.BR pthread_timedjoin_np ()
109T} Thread safety MT-Safe
110.TE
c466875e 111.hy
74714ea8 112.ad
c466875e 113.sp 1
681f0d67 114.SH CONFORMING TO
c8f2dd47 115These functions are nonstandard GNU extensions;
d603cc27 116hence the suffix "_np" (nonportable) in the names.
dae872dd
MK
117.SH BUGS
118The
119.BR pthread_timedjoin_np ()
120function measures time by internally calculating a relative sleep interval
121that is then measured against the
1ae6b2c7 122.B CLOCK_MONOTONIC
dae872dd 123clock instead of the
1ae6b2c7 124.B CLOCK_REALTIME
dae872dd
MK
125clock.
126Consequently, the timeout is unaffected by discontinuous changes to the
1ae6b2c7 127.B CLOCK_REALTIME
dae872dd 128clock.
a14af333 129.SH EXAMPLES
681f0d67 130The following code waits to join for up to 5 seconds:
847e0d88 131.PP
207050fa
MK
132.in +4n
133.EX
134struct timespec ts;
135int s;
681f0d67 136
207050fa 137\&...
681f0d67 138
207050fa
MK
139if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
140 /* Handle error */
141}
681f0d67 142
207050fa 143ts.tv_sec += 5;
681f0d67 144
207050fa
MK
145s = pthread_timedjoin_np(thread, NULL, &ts);
146if (s != 0) {
147 /* Handle error */
148}
b9c93deb 149.EE
207050fa 150.in
681f0d67 151.SH SEE ALSO
0eb44391 152.BR clock_gettime (2),
681f0d67 153.BR pthread_exit (3),
3e5c319e 154.BR pthread_join (3),
e97e048a 155.BR timespec (3),
681f0d67 156.BR pthreads (7)