]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_exit.3
Many pages: Add '\" t' comment where necessary
[thirdparty/man-pages.git] / man3 / pthread_exit.3
CommitLineData
a1eaacb1 1'\" t
c495ab1b
MK
2.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
c495ab1b 6.\"
4c1c5274 7.TH pthread_exit 3 (date) "Linux man-pages (unreleased)"
c495ab1b
MK
8.SH NAME
9pthread_exit \- terminate calling thread
97c89232
AC
10.SH LIBRARY
11POSIX threads library
8fc3b2cf 12.RI ( libpthread ", " \-lpthread )
c495ab1b
MK
13.SH SYNOPSIS
14.nf
15.B #include <pthread.h>
dbfe9c70 16.PP
9b2f5804 17.BI "[[noreturn]] void pthread_exit(void *" retval );
6030f2d8 18.fi
c495ab1b
MK
19.SH DESCRIPTION
20The
21.BR pthread_exit ()
22function terminates the calling thread and returns a value via
23.I retval
24that (if the thread is joinable)
25is available to another thread in the same process that calls
26.BR pthread_join (3).
847e0d88 27.PP
c495ab1b
MK
28Any clean-up handlers established by
29.BR pthread_cleanup_push (3)
30that have not yet been popped,
31are popped (in the reverse of the order in which they were pushed)
32and executed.
33If the thread has any thread-specific data, then,
34after the clean-up handlers have been executed,
35the corresponding destructor functions are called,
36in an unspecified order.
847e0d88 37.PP
c495ab1b
MK
38When a thread terminates,
39process-shared resources (e.g., mutexes, condition variables,
40semaphores, and file descriptors) are not released,
41and functions registered using
42.BR atexit (3)
43are not called.
847e0d88 44.PP
c495ab1b
MK
45After the last thread in a process terminates,
46the process terminates as by calling
47.BR exit (3)
48with an exit status of zero;
49thus, process-shared resources
50are released and functions registered using
51.BR atexit (3)
52are called.
53.SH RETURN VALUE
54This function does not return to the caller.
55.SH ERRORS
56This function always succeeds.
cb63c0fc 57.SH ATTRIBUTES
b1beec8d
PH
58For an explanation of the terms used in this section, see
59.BR attributes (7).
c466875e
MK
60.ad l
61.nh
b1beec8d
PH
62.TS
63allbox;
c466875e 64lbx lb lb
b1beec8d
PH
65l l l.
66Interface Attribute Value
67T{
cb63c0fc 68.BR pthread_exit ()
b1beec8d
PH
69T} Thread safety MT-Safe
70.TE
c466875e
MK
71.hy
72.ad
73.sp 1
3113c7f3 74.SH STANDARDS
9ba60540 75POSIX.1-2001, POSIX.1-2008.
c495ab1b
MK
76.SH NOTES
77Performing a return from the start function of any thread other
78than the main thread results in an implicit call to
79.BR pthread_exit (),
80using the function's return value as the thread's exit status.
847e0d88 81.PP
c495ab1b
MK
82To allow other threads to continue execution,
83the main thread should terminate by calling
79bb6430 84.BR pthread_exit ()
c495ab1b
MK
85rather than
86.BR exit (3).
847e0d88 87.PP
c495ab1b 88The value pointed to by
1ae6b2c7 89.I retval
c495ab1b
MK
90should not be located on the calling thread's stack,
91since the contents of that stack are undefined after the thread terminates.
257f73f2
MK
92.SH BUGS
93Currently,
94.\" Linux 2.6.27
95there are limitations in the kernel implementation logic for
96.BR wait (2)ing
97on a stopped thread group with a dead thread group leader.
98This can manifest in problems such as a locked terminal if a stop signal is
99sent to a foreground process whose thread group leader has already called
27d47e71 100.BR pthread_exit ().
257f73f2
MK
101.\" FIXME . review a later kernel to see if this gets fixed
102.\" http://thread.gmane.org/gmane.linux.kernel/611611
103.\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
c495ab1b
MK
104.SH SEE ALSO
105.BR pthread_create (3),
106.BR pthread_join (3),
107.BR pthreads (7)