OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_tryjoin_np.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_TRYJOIN_NP 3 2010-09-10 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
27 terminated thread
28 .SH SYNOPSIS
29 .nf
30 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
31 .B #include <pthread.h>
32
33 .BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
34
35 .BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
36 .BI "                         const struct timespec *" abstime );
37 .fi
38 .sp
39 Compile and link with \fI\-pthread\fP.
40 .SH DESCRIPTION
41 These functions operate in the same way as
42 .BR pthread_join (3),
43 except for the differences described on this page.
44
45 The
46 .BR pthread_tryjoin_np ()
47 function performs a nonblocking join with the thread
48 .IR thread ,
49 returning the exit status of the thread in
50 .IR *retval .
51 If
52 .I thread
53 has not yet terminated, then instead of blocking, as is done by
54 .BR pthread_join (3),
55 the call returns an error.
56
57 The
58 .BR pthread_timedjoin_np ()
59 function performs a join-with-timeout.
60 If
61 .I thread
62 has not yet terminated,
63 then the call blocks until a maximum time, specified in
64 .IR abstime .
65 If the timeout expires before
66 .I thread
67 terminates,
68 the call returns an error.
69 The
70 .I abstime
71 argument is a structure of the following form,
72 specifying an absolute time measured since the Epoch (see
73 .BR time (2)):
74
75 .in +4n
76 .nf
77 struct timespec {
78     time_t tv_sec;     /* seconds */
79     long   tv_nsec;    /* nanoseconds */
80 };
81 .fi
82 .in
83 .SH RETURN VALUE
84 On success,
85 these functions return 0;
86 on error, they return an error number.
87 .SH ERRORS
88 These functions can fail with the same errors as
89 .BR pthread_join (3).
90 .BR pthread_tryjoin_np ()
91 can in addition fail with the following error:
92 .TP
93 .B EBUSY
94 .I thread
95 had not yet terminated at the time of the call.
96 .PP
97 .BR pthread_timedjoin_np ()
98 can in addition fail with the following error:
99 .TP
100 .BR ETIMEDOUT
101 The call timed out before
102 .I thread
103 terminated.
104 .PP
105 .BR pthread_timedjoin_np ()
106 never returns the error
107 .BR EINTR .
108 .SH VERSIONS
109 These functions first appeared in glibc in version 2.3.3.
110 .SH CONFORMING TO
111 These functions are nonstandard GNU extensions;
112 hence the suffix "_np" (nonportable) in the names.
113 .SH EXAMPLE
114 The following code waits to join for up to 5 seconds:
115
116 .nf
117     struct timespec ts;
118     int s;
119
120     ...
121
122     if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
123         /* Handle error */
124     }
125
126     ts.tv_sec += 5;
127
128     s = pthread_timedjoin_np(thread, NULL, &ts);
129     if (s != 0) {
130         /* Handle error */
131     }
132 .fi
133 .SH SEE ALSO
134 .BR clock_gettime (2),
135 .BR pthread_join (3),
136 .BR pthread_exit (3),
137 .BR pthreads (7)