1.\" $OpenBSD: pthread_exit.3,v 1.7 1999/11/24 05:35:32 d Exp $ 2.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. All advertising materials mentioning features or use of this software 14.\" must display the following acknowledgement: 15.\" This product includes software developed by John Birrell. 16.\" 4. Neither the name of the author nor the names of any co-contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" $FreeBSD: pthread_exit.3,v 1.7 1999/08/28 00:03:06 peter Exp $ 33.\" 34.Dd April 4, 1996 35.Dt PTHREAD_EXIT 3 36.Os 37.Sh NAME 38.Nm pthread_exit 39.Nd terminate the calling thread 40.Sh SYNOPSIS 41.Fd #include <pthread.h> 42.Ft void 43.Fn pthread_exit "void *value_ptr" 44.Sh DESCRIPTION 45The 46.Fn pthread_exit 47function terminates the calling thread and makes the value 48.Fa value_ptr 49available to any successful join with the terminating thread. Any 50cancellation cleanup handlers that have been pushed and are not yet popped 51are popped in the reverse order that they were pushed and then executed. 52After all cancellation handlers have been executed, if the thread has any 53thread-specific data, appropriate destructor functions are called in an 54unspecified order. Thread termination does not release any application 55visible process resources, including, but not limited to, mutexes and 56file descriptors, nor does it perform any process level cleanup 57actions, including, but not limited to, calling 58.Fn atexit 59routines that may exist. 60.Pp 61An implicit call to 62.Fn pthread_exit 63is made when a thread other than the thread in which 64.Fn main 65was first invoked returns from the start routine that was used to create 66it. The function's return value serves as the thread's exit status. 67.Pp 68The behavior of 69.Fn pthread_exit 70is undefied if called from a cancellation handler or destructor function 71that was invoked as the result of an implicit or explicit call to 72.Fn pthread_exit . 73.Pp 74After a thread has terminated, the result of access to local (auto) 75variables of the thread is undefined. Thus, references to local variables 76of the exiting thread should not be used for the 77.Fn pthread_exit 78.Fa value_ptr 79parameter value. 80.Pp 81The process will exit with an exit status of 0 after the last thread has 82been terminated. The behavior is as if the implementation called 83.Fn exit 84with a zero argument at thread termination time. 85.Sh RETURN VALUES 86The 87.Fn pthread_exit 88function cannot return to its caller. 89.Sh ERRORS 90None. 91.Sh SEE ALSO 92.Xr _exit 2 , 93.Xr exit 3 , 94.Xr pthread_create 3 , 95.Xr pthread_join 3 96.Sh STANDARDS 97.Fn pthread_exit 98conforms to ISO/IEC 9945-1 ANSI/IEEE 99.Pq Dq Tn POSIX 100Std 1003.1 Second Edition 1996-07-12. 101