9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / pthread_join.3c
blob7a806973c01b1b8c1131f1ad68e12534e2d32ed1
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1991, 1992, 1994, The X/Open Company Ltd.
44 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
45 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH PTHREAD_JOIN 3C "Mar 23, 2005"
48 .SH NAME
49 pthread_join \- wait for thread termination
50 .SH SYNOPSIS
51 .LP
52 .nf
53 cc -mt [ \fIflag\fR... ] \fIfile\fR... -lpthread [ \fIlibrary\fR... ]
54 #include <pthread.h>
56 \fBint\fR \fBpthread_join\fR(\fBpthread_t\fR \fIthread\fR, \fBvoid **\fR\fIstatus\fR);
57 .fi
59 .SH DESCRIPTION
60 .sp
61 .LP
62 The \fBpthread_join()\fR function suspends processing of the calling thread
63 until the target \fIthread\fR completes. \fIthread\fR must be a member of the
64 current process and it cannot be a detached thread. See
65 \fBpthread_create\fR(3C).
66 .sp
67 .LP
68 If two or more threads wait for the same thread to complete, all will suspend
69 processing until the thread has terminated, and then one thread will return
70 successfully and the others will return with an error of \fBESRCH\fR. The
71 \fBpthread_join()\fR function will not block processing of the calling thread
72 if the target \fIthread\fR has already terminated.
73 .sp
74 .LP
75 If a \fBpthread_join()\fR call returns successfully with a non-null
76 \fIstatus\fR argument, the value passed to \fBpthread_exit\fR(3C) by the
77 terminating thread will be placed in the location referenced by \fIstatus\fR.
78 .sp
79 .LP
80 If the \fBpthread_join()\fR calling thread is cancelled, then the target
81 \fIthread\fR will remain joinable by \fBpthread_join()\fR. However, the calling
82 thread may set up a cancellation cleanup handler on \fIthread\fR prior to the
83 join call, which may detach the target \fIthread\fR by calling
84 \fBpthread_detach\fR(3C). See \fBpthread_detach\fR(3C) and
85 \fBpthread_cancel\fR(3C).
86 .SH RETURN VALUES
87 .sp
88 .LP
89 If successful, \fBpthread_join()\fR returns \fB0\fR. Otherwise, an error number
90 is returned to indicate the error.
91 .SH ERRORS
92 .sp
93 .ne 2
94 .na
95 \fB\fBEDEADLK\fR\fR
96 .ad
97 .RS 11n
98 A joining deadlock would occur, such as when a thread attempts to wait for
99 itself.
103 .ne 2
105 \fB\fBEINVAL\fR\fR
107 .RS 11n
108 The thread corresponding to the given thread ID is a detached thread.
112 .ne 2
114 \fB\fBESRCH\fR\fR
116 .RS 11n
117 No thread could be found corresponding to the given thread ID.
120 .SH ATTRIBUTES
123 See \fBattributes\fR(5) for descriptions of the following attributes:
128 box;
129 c | c
130 l | l .
131 ATTRIBUTE TYPE  ATTRIBUTE VALUE
133 Interface Stability     Standard
135 MT-Level        MT-Safe
138 .SH SEE ALSO
141 \fBpthread_cancel\fR(3C), \fBpthread_create\fR(3C), \fBpthread_detach\fR(3C),
142 \fBpthread_exit\fR(3C), \fBwait\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
143 .SH NOTES
146 The pthread_join(3C) function must specify the \fIthread\fR \fBID\fR for whose
147 termination it will wait.
150 Calling \fBpthread_join()\fR also "detaches" the thread; that is,
151 \fBpthread_join()\fR includes the effect of the \fBpthread_detach()\fR
152 function. If a thread were to be cancelled when blocked in
153 \fBpthread_join()\fR, an explicit detach would have to be performed in the
154 cancellation cleanup handler. The \fBpthread_detach()\fR function exists
155 primarily for this purpose.