1951 leaking a vdev when removing an l2cache device
[unleashed.git] / usr / src / man / man3c / thr_join.3c
blob35c42ea216990428534c7e79002ed0a2fef4ddb3
1 '\" te
2 .\" Copyright (c) 2000 Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
4 .\" Portions Copyright (c) 1995 IEEE  All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH THR_JOIN 3C "Mar 27, 2000"
13 .SH NAME
14 thr_join \- wait for thread termination
15 .SH SYNOPSIS
16 .LP
17 .nf
18 cc -mt [ \fIflag\fR... ] \fIfile\fR...[ \fIlibrary\fR... ]
19 #include <thread.h>
21 \fBint\fR \fBthr_join\fR(\fBthread_t\fR \fIthread\fR, \fBthread_t *\fR\fIdeparted\fR, \fBvoid **\fR\fIstatus\fR);
22 .fi
24 .SH DESCRIPTION
25 .sp
26 .LP
27 The \fBthr_join()\fR function suspends processing of the calling thread until
28 the target \fIthread\fR completes. The \fIthread\fR argument must be a member
29 of the current process and cannot be a detached thread. See
30 \fBthr_create\fR(3C).
31 .sp
32 .LP
33 If two or more threads wait for the same thread to complete, all will suspend
34 processing until the thread has terminated, and then one thread will return
35 successfully and the others will return with an error of \fBESRCH\fR. The
36 \fBthr_join()\fR function will not block processing of the calling thread if
37 the target \fIthread\fR has already terminated.
38 .sp
39 .LP
40 If a \fBthr_join()\fR call returns successfully with a non-null \fIstatus\fR
41 argument, the value passed to \fBthr_exit\fR(3C) by the terminating thread will
42 be placed in the location referenced by \fIstatus\fR.
43 .sp
44 .LP
45 If the target \fIthread\fR \fBID\fR is  \fB0\fR, \fBthr_join()\fR finds and
46 returns the status of a terminated undetached thread in the process. If no such
47 thread exists, it suspends processing of the calling thread until a thread for
48 which no other thread is waiting enters that state, at which time it returns
49 successfully, or until all other threads in the process are either daemon
50 threads or threads waiting in \fBthr_join()\fR, in which case it returns
51 \fBEDEADLK\fR. See \fBNOTES\fR.
52 .sp
53 .LP
54 If \fIdeparted\fR is not \fINULL\fR, it points to a location that is set to the
55 ID of the terminated thread if \fBthr_join()\fR returns successfully.
56 .SH RETURN VALUES
57 .sp
58 .LP
59 If successful, \fBthr_join()\fR returns \fB0\fR. Otherwise, an error number is
60 returned to indicate the error.
61 .SH ERRORS
62 .sp
63 .ne 2
64 .na
65 \fB\fBEDEADLK\fR \fR
66 .ad
67 .RS 12n
68 A joining deadlock would occur, such as when a thread attempts to wait for
69 itself, or the calling thread is waiting for any thread to exit and only daemon
70 threads or waiting threads exist in the process.
71 .RE
73 .sp
74 .ne 2
75 .na
76 \fB\fBESRCH\fR \fR
77 .ad
78 .RS 12n
79 No undetached thread could be found corresponding to the given thread ID.
80 .RE
82 .SH ATTRIBUTES
83 .sp
84 .LP
85 See \fBattributes\fR(5) for descriptions of the following attributes:
86 .sp
88 .sp
89 .TS
90 box;
91 c | c
92 l | l .
93 ATTRIBUTE TYPE  ATTRIBUTE VALUE
95 MT-Level        MT-Safe
96 .TE
98 .SH SEE ALSO
99 .sp
101 \fBthr_create\fR(3C), \fBthr_exit\fR(3C), \fBwait\fR(3C), \fBattributes\fR(5),
102 \fBstandards\fR(5)
103 .SH NOTES
106 Using thr_join(3C) in the following syntax,
108 .in +2
110 while (thr_join(0, NULL, NULL) == 0);
112 .in -2
116 will wait for the termination of all non-daemon threads, excluding threads that
117 are themselves waiting in \fBthr_join()\fR.