1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH PTHREAD_EXIT 3 2021-03-22 "Linux" "Linux Programmer's Manual"
28 pthread_exit \- terminate calling thread
31 .B #include <pthread.h>
33 .BI "noreturn void pthread_exit(void *" retval );
35 Compile and link with \fI\-pthread\fP.
40 function terminates the calling thread and returns a value via
42 that (if the thread is joinable)
43 is available to another thread in the same process that calls
46 Any clean-up handlers established by
47 .BR pthread_cleanup_push (3)
48 that have not yet been popped,
49 are popped (in the reverse of the order in which they were pushed)
51 If the thread has any thread-specific data, then,
52 after the clean-up handlers have been executed,
53 the corresponding destructor functions are called,
54 in an unspecified order.
56 When a thread terminates,
57 process-shared resources (e.g., mutexes, condition variables,
58 semaphores, and file descriptors) are not released,
59 and functions registered using
63 After the last thread in a process terminates,
64 the process terminates as by calling
66 with an exit status of zero;
67 thus, process-shared resources
68 are released and functions registered using
72 This function does not return to the caller.
74 This function always succeeds.
76 For an explanation of the terms used in this section, see
84 Interface Attribute Value
87 T} Thread safety MT-Safe
93 POSIX.1-2001, POSIX.1-2008.
95 Performing a return from the start function of any thread other
96 than the main thread results in an implicit call to
98 using the function's return value as the thread's exit status.
100 To allow other threads to continue execution,
101 the main thread should terminate by calling
106 The value pointed to by
108 should not be located on the calling thread's stack,
109 since the contents of that stack are undefined after the thread terminates.
113 there are limitations in the kernel implementation logic for
115 on a stopped thread group with a dead thread group leader.
116 This can manifest in problems such as a locked terminal if a stop signal is
117 sent to a foreground process whose thread group leader has already called
119 .\" FIXME . review a later kernel to see if this gets fixed
120 .\" http://thread.gmane.org/gmane.linux.kernel/611611
121 .\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
123 .BR pthread_create (3),
124 .BR pthread_join (3),