import less(1)
[unleashed/tickless.git] / share / man / man3c / thr_exit.3c
bloba668c23250c0ef835ad2c55df978298e853439d6
1 '\" te
2 .\" Copyright (c) 2007 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_EXIT 3C "Nov 2, 2007"
13 .SH NAME
14 thr_exit \- terminate the calling thread
15 .SH SYNOPSIS
16 .LP
17 .nf
18 cc -mt [ \fIflag\fR... ] \fIfile\fR...[ \fIlibrary\fR... ]
19 #include <thread.h>
21 \fBvoid\fR \fBthr_exit\fR(\fBvoid *\fR\fIstatus\fR);
22 .fi
24 .SH DESCRIPTION
25 .sp
26 .LP
27 The \fBthr_exit()\fR function terminates the calling thread, in a similar way
28 that \fBexit\fR(3C) terminates the calling process. If the calling thread is
29 not detached, then the thread's \fBID\fR and the exit status specified by
30 \fIstatus\fR are retained. The value \fIstatus\fR is then made available to any
31 successful join with the terminating thread (see \fBthr_join\fR(3C));
32 otherwise, \fIstatus\fR is disregarded allowing the thread's ID to be reclaimed
33 immediately.
34 .sp
35 .LP
36 Any cancellation cleanup handlers that have been pushed and not yet popped are
37 popped in the reverse order that they were pushed and then executed. After all
38 cancellation cleanup handlers have been executed, if the thread has any
39 thread-specific data, appropriate destructor functions will be called in an
40 unspecified order. Thread termination does not release any application visible
41 process resources, including, but not limited to, mutexes and file descriptors,
42 nor does it perform any process level cleanup actions, including, but not
43 limited to, calling any \fBatexit()\fR routines that might exist.
44 .sp
45 .LP
46 An exiting thread runs with all signals blocked. All thread termination
47 functions, including cancellation cleanup handlers and thread-specific data
48 destructor functions, are called with all signals blocked.
49 .sp
50 .LP
51 If any thread, including the  \fBmain()\fR thread, calls \fBthr_exit()\fR, only
52 that thread will exit.
53 .sp
54 .LP
55 If \fBmain()\fR returns or exits (either implicitly or explicitly), or any
56 thread explicitly calls \fBexit()\fR, the entire process will exit.
57 .sp
58 .LP
59 The behavior of \fBthr_exit()\fR is undefined if called from a cancellation
60 cleanup handler or destructor function that was invoked as a result of either
61 an implicit or explicit call to \fBthr_exit()\fR.
62 .sp
63 .LP
64 After a thread has terminated, the result of access to local (auto) variables
65 of the thread is undefined. Thus, references to local variables of the exiting
66 thread should not be used for the \fBthr_exit()\fR \fIstatus\fR parameter
67 value.
68 .sp
69 .LP
70 If any thread (except the \fBmain()\fR thread) implicitly or explicitly
71 returns, the result is the same as if the thread called \fBthr_exit()\fR and it
72 will return the value of \fIstatus\fR as the exit code.
73 .sp
74 .LP
75 The process will terminate with an exit status of \fB0\fR after the last
76 non-daemon thread has terminated (including the \fBmain()\fR thread). This
77 behavior is the same as if the application had called \fBexit()\fR with a
78 \fB0\fR argument at thread termination time.
79 .SH RETURN VALUES
80 .sp
81 .LP
82 The  \fBthr_exit()\fR function cannot return to its caller.
83 .SH ERRORS
84 .sp
85 .LP
86 No errors are defined.
87 .SH ATTRIBUTES
88 .sp
89 .LP
90 See \fBattributes\fR(5) for descriptions of the following attributes:
91 .sp
93 .sp
94 .TS
95 box;
96 c | c
97 l | l .
98 ATTRIBUTE TYPE  ATTRIBUTE VALUE
100 MT-Level        MT-Safe
103 .SH SEE ALSO
106 \fBexit\fR(3C), \fBthr_create\fR(3C), \fBthr_join\fR(3C),
107 \fBthr_keycreate\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
108 .SH NOTES
111 Although only POSIX implements cancellation, cancellation can be used with
112 Solaris threads, due to their interoperability.
115 The \fIstatus\fR argument should not reference any variables local to the
116 calling thread.