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
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 error:
52
53       ETIMEDOUT
54              The call timed out before thread terminated.
55
56       pthread_timedjoin_np() never returns the error EINTR.
57

VERSIONS

59       These functions first appeared in glibc in version 2.3.3.
60

CONFORMING TO

62       These  functions are nonstandard GNU extensions; hence the suffix "_np"
63       (nonportable) in the names.
64

EXAMPLE

66       The following code waits to join for up to 5 seconds:
67
68           struct timespec ts;
69           int s;
70
71           ...
72
73           if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
74            /* Handle error */
75           }
76
77           ts.tv_sec += 5;
78
79           s = pthread_timedjoin_np(thread, NULL, &ts);
80           if (s != 0) {
81               /* Handle error */
82           }
83

SEE ALSO

85       clock_gettime(2), pthread_join(3), pthread_exit(3), pthreads(7)
86

COLOPHON

88       This page is part of release 3.25 of the Linux  man-pages  project.   A
89       description  of  the project, and information about reporting bugs, can
90       be found at http://www.kernel.org/doc/man-pages/.
91
92
93
94Linux                             2008-11-11             PTHREAD_TRYJOIN_NP(3)
Impressum