2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH pthread_exit 3 (date) "Linux man-pages (unreleased)"
9 pthread_exit \- terminate calling thread
12 .RI ( libpthread ", " \-lpthread )
15 .B #include <pthread.h>
17 .BI "[[noreturn]] void pthread_exit(void *" retval );
22 function terminates the calling thread and returns a value via
24 that (if the thread is joinable)
25 is available to another thread in the same process that calls
28 Any clean-up handlers established by
29 .BR pthread_cleanup_push (3)
30 that have not yet been popped,
31 are popped (in the reverse of the order in which they were pushed)
33 If the thread has any thread-specific data, then,
34 after the clean-up handlers have been executed,
35 the corresponding destructor functions are called,
36 in an unspecified order.
38 When a thread terminates,
39 process-shared resources (e.g., mutexes, condition variables,
40 semaphores, and file descriptors) are not released,
41 and functions registered using
45 After the last thread in a process terminates,
46 the process terminates as by calling
48 with an exit status of zero;
49 thus, process-shared resources
50 are released and functions registered using
54 This function does not return to the caller.
56 This function always succeeds.
58 For an explanation of the terms used in this section, see
66 Interface Attribute Value
69 T} Thread safety MT-Safe
75 POSIX.1-2001, POSIX.1-2008.
77 Performing a return from the start function of any thread other
78 than the main thread results in an implicit call to
80 using the function's return value as the thread's exit status.
82 To allow other threads to continue execution,
83 the main thread should terminate by calling
88 The value pointed to by
90 should not be located on the calling thread's stack,
91 since the contents of that stack are undefined after the thread terminates.
95 there are limitations in the kernel implementation logic for
97 on a stopped thread group with a dead thread group leader.
98 This can manifest in problems such as a locked terminal if a stop signal is
99 sent to a foreground process whose thread group leader has already called
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
105 .BR pthread_create (3),
106 .BR pthread_join (3),