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