Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/pthread_exit.html
2024-02-19 00:21:47 -05:00

149 lines
6.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>pthread_exit</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="pthread_exit"></a> <a name="tag_03_528"></a><!-- pthread_exit -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_528_01"></a>NAME</h4>
<blockquote>pthread_exit - thread termination</blockquote>
<h4><a name="tag_03_528_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('THR')">THR</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> #include &lt;<a href="../basedefs/pthread.h.html">pthread.h</a>&gt;<br>
<br>
void pthread_exit(void *</tt><i>value_ptr</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_528_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>pthread_exit</i>() function shall terminate the calling thread and make the value <i>value_ptr</i> available to any
successful join with the terminating thread. Any cancelation cleanup handlers that have been pushed and not yet popped shall be
popped in the reverse order that they were pushed and then executed. After all cancelation cleanup handlers have been executed, if
the thread has any thread-specific data, appropriate destructor functions shall be called in an unspecified order. Thread
termination does not release any application visible process resources, including, but not limited to, mutexes and file
descriptors, nor does it perform any process-level cleanup actions, including, but not limited to, calling any <a href=
"../functions/atexit.html"><i>atexit</i>()</a> routines that may exist.</p>
<p>An implicit call to <i>pthread_exit</i>() is made when a thread other than the thread in which <i>main</i>() was first invoked
returns from the start routine that was used to create it. The function's return value shall serve as the thread's exit status.</p>
<p>The behavior of <i>pthread_exit</i>() is undefined if called from a cancelation cleanup handler or destructor function that was
invoked as a result of either an implicit or explicit call to <i>pthread_exit</i>().</p>
<p>After a thread has terminated, the result of access to local (auto) variables of the thread is undefined. Thus, references to
local variables of the exiting thread should not be used for the <i>pthread_exit</i>() <i>value_ptr</i> parameter value.</p>
<p>The process shall exit with an exit status of 0 after the last thread has been terminated. The behavior shall be as if the
implementation called <a href="../functions/exit.html"><i>exit</i>()</a> with a zero argument at thread termination time.</p>
</blockquote>
<h4><a name="tag_03_528_04"></a>RETURN VALUE</h4>
<blockquote>
<p>The <i>pthread_exit</i>() function cannot return to its caller.</p>
</blockquote>
<h4><a name="tag_03_528_05"></a>ERRORS</h4>
<blockquote>
<p>No errors are defined.</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_528_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_528_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_528_08"></a>RATIONALE</h4>
<blockquote>
<p>The normal mechanism by which a thread terminates is to return from the routine that was specified in the <a href=
"../functions/pthread_create.html"><i>pthread_create</i>()</a> call that started it. The <i>pthread_exit</i>() function provides
the capability for a thread to terminate without requiring a return from the start routine of that thread, thereby providing a
function analogous to <a href="../functions/exit.html"><i>exit</i>()</a>.</p>
<p>Regardless of the method of thread termination, any cancelation cleanup handlers that have been pushed and not yet popped are
executed, and the destructors for any existing thread-specific data are executed. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001
requires that cancelation cleanup handlers be popped and called in order. After all cancelation cleanup handlers have been
executed, thread-specific data destructors are called, in an unspecified order, for each item of thread-specific data that exists
in the thread. This ordering is necessary because cancelation cleanup handlers may rely on thread-specific data.</p>
<p>As the meaning of the status is determined by the application (except when the thread has been canceled, in which case it is
PTHREAD_CANCELED), the implementation has no idea what an illegal status value is, which is why no address error checking is
done.</p>
</blockquote>
<h4><a name="tag_03_528_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_528_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="exit.html"><i>exit</i>()</a> , <a href="pthread_create.html"><i>pthread_create</i>()</a> , <a href=
"pthread_join.html"><i>pthread_join</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/pthread.h.html"><i>&lt;pthread.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_528_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 5. Included for alignment with the POSIX Threads Extension.</p>
</blockquote>
<h4><a name="tag_03_528_12"></a>Issue 6</h4>
<blockquote>
<p>The <i>pthread_exit</i>() function is marked as part of the Threads option.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>