1PTHREAD_TRYJOIN_NP(3)      Linux Programmer's Manual     PTHREAD_TRYJOIN_NP(3)
2
3
4

NAME

6       pthread_tryjoin_np,  pthread_timedjoin_np  -  try to join with a termi‐
7       nated thread
8

SYNOPSIS

10       #define _GNU_SOURCE             /* See feature_test_macros(7) */
11       #include <pthread.h>
12
13       int pthread_tryjoin_np(pthread_t thread, void **retval);
14
15       int pthread_timedjoin_np(pthread_t thread, void **retval,
16                                const struct timespec *abstime);
17
18       Compile and link with -pthread.
19

DESCRIPTION

21       These functions operate in the same way as pthread_join(3), except  for
22       the differences described on this page.
23
24       The  pthread_tryjoin_np() function performs a nonblocking join with the
25       thread thread, returning the exit status of the thread in *retval.   If
26       thread  has not yet terminated, then instead of blocking, as is done by
27       pthread_join(3), the call returns an error.
28
29       The pthread_timedjoin_np() function performs a  join-with-timeout.   If
30       thread  has  not  yet  terminated, then the call blocks until a maximum
31       time, specified in abstime.  If the timeout expires before thread  ter‐
32       minates,  the  call returns an error.  The abstime argument is a struc‐
33       ture of the following form, specifying an absolute time measured  since
34       the Epoch (see time(2)):
35
36           struct timespec {
37               time_t tv_sec;     /* seconds */
38               long   tv_nsec;    /* nanoseconds */
39           };
40

RETURN VALUE

42       On  success,  these  functions return 0; on error, they return an error
43       number.
44

ERRORS

46       These functions can fail  with  the  same  errors  as  pthread_join(3).
47       pthread_tryjoin_np() can in addition fail with the following error:
48
49       EBUSY  thread had not yet terminated at the time of the call.
50
51       pthread_timedjoin_np() can in addition fail with the following errors:
52
53       ETIMEDOUT
54              The call timed out before thread terminated.
55
56       EINVAL abstime  value  is  invalid (tv_sec is less than 0 or tv_nsec is
57              greater than 1e9).
58
59       pthread_timedjoin_np() never returns the error EINTR.
60

VERSIONS

62       These functions first appeared in glibc in version 2.3.3.
63

ATTRIBUTES

65       For  an  explanation  of  the  terms  used   in   this   section,   see
66       attributes(7).
67
68       ┌───────────────────────┬───────────────┬─────────┐
69Interface              Attribute     Value   
70       ├───────────────────────┼───────────────┼─────────┤
71pthread_tryjoin_np(),  │ Thread safety │ MT-Safe │
72pthread_timedjoin_np() │               │         │
73       └───────────────────────┴───────────────┴─────────┘

CONFORMING TO

75       These functions are nonstandard GNU extensions; hence the suffix  "_np"
76       (nonportable) in the names.
77

EXAMPLE

79       The following code waits to join for up to 5 seconds:
80
81           struct timespec ts;
82           int s;
83
84           ...
85
86           if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
87               /* Handle error */
88           }
89
90           ts.tv_sec += 5;
91
92           s = pthread_timedjoin_np(thread, NULL, &ts);
93           if (s != 0) {
94               /* Handle error */
95           }
96

SEE ALSO

98       clock_gettime(2), pthread_exit(3), pthread_join(3), pthreads(7)
99

COLOPHON

101       This  page  is  part of release 5.04 of the Linux man-pages project.  A
102       description of the project, information about reporting bugs,  and  the
103       latest     version     of     this    page,    can    be    found    at
104       https://www.kernel.org/doc/man-pages/.
105
106
107
108Linux                             2017-09-15             PTHREAD_TRYJOIN_NP(3)
Impressum