1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH PTHREAD_EXIT 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
8 pthread_exit \- terminate calling thread
11 .RI ( libpthread ", " \-lpthread )
14 .B #include <pthread.h>
16 .BI "noreturn void pthread_exit(void *" retval );
21 function terminates the calling thread and returns a value via
23 that (if the thread is joinable)
24 is available to another thread in the same process that calls
27 Any clean-up handlers established by
28 .BR pthread_cleanup_push (3)
29 that have not yet been popped,
30 are popped (in the reverse of the order in which they were pushed)
32 If the thread has any thread-specific data, then,
33 after the clean-up handlers have been executed,
34 the corresponding destructor functions are called,
35 in an unspecified order.
37 When a thread terminates,
38 process-shared resources (e.g., mutexes, condition variables,
39 semaphores, and file descriptors) are not released,
40 and functions registered using
44 After the last thread in a process terminates,
45 the process terminates as by calling
47 with an exit status of zero;
48 thus, process-shared resources
49 are released and functions registered using
53 This function does not return to the caller.
55 This function always succeeds.
57 For an explanation of the terms used in this section, see
65 Interface Attribute Value
68 T} Thread safety MT-Safe
74 POSIX.1-2001, POSIX.1-2008.
76 Performing a return from the start function of any thread other
77 than the main thread results in an implicit call to
79 using the function's return value as the thread's exit status.
81 To allow other threads to continue execution,
82 the main thread should terminate by calling
87 The value pointed to by
89 should not be located on the calling thread's stack,
90 since the contents of that stack are undefined after the thread terminates.
94 there are limitations in the kernel implementation logic for
96 on a stopped thread group with a dead thread group leader.
97 This can manifest in problems such as a locked terminal if a stop signal is
98 sent to a foreground process whose thread group leader has already called
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
104 .BR pthread_create (3),
105 .BR pthread_join (3),