OSDN Git Service

LDP: Update original to LDP v3.68
[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 .\" %%%LICENSE_START(VERBATIM)
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH PTHREAD_TRYJOIN_NP 3 2010-09-10 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
29 terminated thread
30 .SH SYNOPSIS
31 .nf
32 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
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 ,
38 .BI "                         const struct timespec *" abstime );
39 .fi
40 .sp
41 Compile and link with \fI\-pthread\fP.
42 .SH DESCRIPTION
43 These functions operate in the same way as
44 .BR pthread_join (3),
45 except for the differences described on this page.
46
47 The
48 .BR pthread_tryjoin_np ()
49 function performs a nonblocking join with the thread
50 .IR thread ,
51 returning the exit status of the thread in
52 .IR *retval .
53 If
54 .I thread
55 has not yet terminated, then instead of blocking, as is done by
56 .BR pthread_join (3),
57 the call returns an error.
58
59 The
60 .BR pthread_timedjoin_np ()
61 function performs a join-with-timeout.
62 If
63 .I thread
64 has not yet terminated,
65 then the call blocks until a maximum time, specified in
66 .IR abstime .
67 If the timeout expires before
68 .I thread
69 terminates,
70 the call returns an error.
71 The
72 .I abstime
73 argument is a structure of the following form,
74 specifying an absolute time measured since the Epoch (see
75 .BR time (2)):
76
77 .in +4n
78 .nf
79 struct timespec {
80     time_t tv_sec;     /* seconds */
81     long   tv_nsec;    /* nanoseconds */
82 };
83 .fi
84 .in
85 .SH RETURN VALUE
86 On success,
87 these functions return 0;
88 on error, they return an error number.
89 .SH ERRORS
90 These functions can fail with the same errors as
91 .BR pthread_join (3).
92 .BR pthread_tryjoin_np ()
93 can in addition fail with the following error:
94 .TP
95 .B EBUSY
96 .I thread
97 had not yet terminated at the time of the call.
98 .PP
99 .BR pthread_timedjoin_np ()
100 can in addition fail with the following error:
101 .TP
102 .BR ETIMEDOUT
103 The call timed out before
104 .I thread
105 terminated.
106 .PP
107 .BR pthread_timedjoin_np ()
108 never returns the error
109 .BR EINTR .
110 .SH VERSIONS
111 These functions first appeared in glibc in version 2.3.3.
112 .SH CONFORMING TO
113 These functions are nonstandard GNU extensions;
114 hence the suffix "_np" (nonportable) in the names.
115 .SH EXAMPLE
116 The following code waits to join for up to 5 seconds:
117
118 .nf
119     struct timespec ts;
120     int s;
121
122     ...
123
124     if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
125         /* Handle error */
126     }
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
136 .BR clock_gettime (2),
137 .BR pthread_exit (3),
138 .BR pthread_join (3),
139 .BR pthreads (7)
140 .SH COLOPHON
141 This page is part of release 3.68 of the Linux
142 .I man-pages
143 project.
144 A description of the project,
145 information about reporting bugs,
146 and the latest version of this page,
147 can be found at
148 \%http://www.kernel.org/doc/man\-pages/.