xref: /netbsd-src/lib/libpthread/pthread_exit.3 (revision 9c4ae7f5c2fef0e300beb637a5dd6fc26ce31b37)
1*9c4ae7f5Sjruoho.\" $NetBSD: pthread_exit.3,v 1.5 2010/07/09 08:51:28 jruoho Exp $
255818196Snathanw.\"
355818196Snathanw.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
455818196Snathanw.\" All rights reserved.
555818196Snathanw.\" Redistribution and use in source and binary forms, with or without
655818196Snathanw.\" modification, are permitted provided that the following conditions
755818196Snathanw.\" are met:
855818196Snathanw.\" 1. Redistributions of source code must retain the above copyright
955818196Snathanw.\"    notice, this list of conditions and the following disclaimer.
1055818196Snathanw.\" 2. Redistributions in binary form must reproduce the above copyright
1155818196Snathanw.\"    notice, this list of conditions and the following disclaimer in the
1255818196Snathanw.\"    documentation and/or other materials provided with the distribution.
13cd22f25eSmartin.\"
1455818196Snathanw.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1555818196Snathanw.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1655818196Snathanw.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1755818196Snathanw.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1855818196Snathanw.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1955818196Snathanw.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2055818196Snathanw.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2155818196Snathanw.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2255818196Snathanw.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2355818196Snathanw.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2455818196Snathanw.\" POSSIBILITY OF SUCH DAMAGE.
2555818196Snathanw.\"
2655818196Snathanw.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
2755818196Snathanw.\" All rights reserved.
2855818196Snathanw.\"
2955818196Snathanw.\" Redistribution and use in source and binary forms, with or without
3055818196Snathanw.\" modification, are permitted provided that the following conditions
3155818196Snathanw.\" are met:
3255818196Snathanw.\" 1. Redistributions of source code must retain the above copyright
3355818196Snathanw.\"    notice, this list of conditions and the following disclaimer.
3455818196Snathanw.\" 2. Redistributions in binary form must reproduce the above copyright
3555818196Snathanw.\"    notice, this list of conditions and the following disclaimer in the
3655818196Snathanw.\"    documentation and/or other materials provided with the distribution.
3755818196Snathanw.\" 3. All advertising materials mentioning features or use of this software
3855818196Snathanw.\"    must display the following acknowledgement:
3955818196Snathanw.\"	This product includes software developed by John Birrell.
4055818196Snathanw.\" 4. Neither the name of the author nor the names of any co-contributors
4155818196Snathanw.\"    may be used to endorse or promote products derived from this software
4255818196Snathanw.\"    without specific prior written permission.
4355818196Snathanw.\"
4455818196Snathanw.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
4555818196Snathanw.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4655818196Snathanw.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4755818196Snathanw.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4855818196Snathanw.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4955818196Snathanw.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5055818196Snathanw.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5155818196Snathanw.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5255818196Snathanw.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5355818196Snathanw.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5455818196Snathanw.\" SUCH DAMAGE.
5555818196Snathanw.\"
5655818196Snathanw.\" $FreeBSD: src/lib/libpthread/man/pthread_exit.3,v 1.16 2002/09/16 19:29:28 mini Exp $
5755818196Snathanw.\"
58*9c4ae7f5Sjruoho.Dd July 9, 2010
5955818196Snathanw.Dt PTHREAD_EXIT 3
6055818196Snathanw.Os
6155818196Snathanw.Sh NAME
6255818196Snathanw.Nm pthread_exit
6355818196Snathanw.Nd terminate the calling thread
6455818196Snathanw.Sh LIBRARY
6555818196Snathanw.Lb libpthread
6655818196Snathanw.Sh SYNOPSIS
6755818196Snathanw.In pthread.h
6855818196Snathanw.Ft void
6955818196Snathanw.Fn pthread_exit "void *value_ptr"
7055818196Snathanw.Sh DESCRIPTION
7155818196SnathanwThe
7255818196Snathanw.Fn pthread_exit
7355818196Snathanwfunction terminates the calling thread and makes the value
7455818196Snathanw.Fa value_ptr
7555818196Snathanwavailable to any successful join with the terminating thread.
7655818196SnathanwAny
7755818196Snathanwcancellation cleanup handlers that have been pushed and are not yet popped
7855818196Snathanware popped in the reverse order that they were pushed and then executed.
7955818196SnathanwAfter all cancellation handlers have been executed, if the thread has any
8055818196Snathanwthread-specific data, appropriate destructor functions are called in an
8155818196Snathanwunspecified order.
8255818196SnathanwThread termination does not release any application
8355818196Snathanwvisible process resources, including, but not limited to, mutexes and
8455818196Snathanwfile descriptors, nor does it perform any process level cleanup
8555818196Snathanwactions, including, but not limited to, calling
8655818196Snathanw.Fn atexit
8755818196Snathanwroutines that may exist.
8855818196Snathanw.Pp
8955818196SnathanwAn implicit call to
9055818196Snathanw.Fn pthread_exit
9155818196Snathanwis made when a thread other than the thread in which
9255818196Snathanw.Fn main
9355818196Snathanwwas first invoked returns from the start routine that was used to create
9463e8a90eSwizit.
9563e8a90eSwizThe function's return value serves as the thread's exit status.
9655818196Snathanw.Pp
9755818196SnathanwThe behavior of
9855818196Snathanw.Fn pthread_exit
9955818196Snathanwis undefined if called from a cancellation handler or destructor function
10055818196Snathanwthat was invoked as the result of an implicit or explicit call to
10155818196Snathanw.Fn pthread_exit .
10255818196Snathanw.Pp
10355818196SnathanwAfter a thread has terminated, the result of access to local (auto)
10455818196Snathanwvariables of the thread is undefined.
10555818196SnathanwThus, references to local variables
10655818196Snathanwof the exiting thread should not be used for the
10755818196Snathanw.Fn pthread_exit
10855818196Snathanw.Fa value_ptr
10955818196Snathanwparameter value.
11055818196Snathanw.Pp
11155818196SnathanwThe process will exit with an exit status of 0 after the last thread has
11255818196Snathanwbeen terminated.
11355818196SnathanwThe behavior is as if the implementation called
11455818196Snathanw.Fn exit
11555818196Snathanwwith a zero argument at thread termination time.
11655818196Snathanw.Sh RETURN VALUES
11755818196SnathanwThe
11855818196Snathanw.Fn pthread_exit
11955818196Snathanwfunction cannot return to its caller.
12055818196Snathanw.Sh ERRORS
12155818196SnathanwNone.
12255818196Snathanw.Sh SEE ALSO
12355818196Snathanw.Xr _exit 2 ,
12455818196Snathanw.Xr exit 3 ,
12555818196Snathanw.Xr pthread_create 3 ,
12655818196Snathanw.Xr pthread_join 3
12755818196Snathanw.Sh STANDARDS
128*9c4ae7f5SjruohoThe function conforms to
129*9c4ae7f5Sjruoho.St -p1003.1-2001 .
130