]>
Commit | Line | Data |
---|---|---|
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 |
9 | pthread_exit \- terminate calling thread | |
97c89232 AC |
10 | .SH LIBRARY |
11 | POSIX 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 |
20 | The | |
21 | .BR pthread_exit () | |
22 | function terminates the calling thread and returns a value via | |
23 | .I retval | |
24 | that (if the thread is joinable) | |
25 | is available to another thread in the same process that calls | |
26 | .BR pthread_join (3). | |
847e0d88 | 27 | .PP |
c495ab1b MK |
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) | |
32 | and executed. | |
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. | |
847e0d88 | 37 | .PP |
c495ab1b MK |
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 | |
42 | .BR atexit (3) | |
43 | are not called. | |
847e0d88 | 44 | .PP |
c495ab1b MK |
45 | After the last thread in a process terminates, |
46 | the process terminates as by calling | |
47 | .BR exit (3) | |
48 | with an exit status of zero; | |
49 | thus, process-shared resources | |
50 | are released and functions registered using | |
51 | .BR atexit (3) | |
52 | are called. | |
53 | .SH RETURN VALUE | |
54 | This function does not return to the caller. | |
55 | .SH ERRORS | |
56 | This function always succeeds. | |
cb63c0fc | 57 | .SH ATTRIBUTES |
b1beec8d PH |
58 | For an explanation of the terms used in this section, see |
59 | .BR attributes (7). | |
60 | .TS | |
61 | allbox; | |
c466875e | 62 | lbx lb lb |
b1beec8d PH |
63 | l l l. |
64 | Interface Attribute Value | |
65 | T{ | |
9e54434e BR |
66 | .na |
67 | .nh | |
cb63c0fc | 68 | .BR pthread_exit () |
b1beec8d PH |
69 | T} Thread safety MT-Safe |
70 | .TE | |
c466875e | 71 | .sp 1 |
3113c7f3 | 72 | .SH STANDARDS |
4131356c AC |
73 | POSIX.1-2008. |
74 | .SH HISTORY | |
75 | POSIX.1-2001. | |
c495ab1b MK |
76 | .SH NOTES |
77 | Performing a return from the start function of any thread other | |
78 | than the main thread results in an implicit call to | |
79 | .BR pthread_exit (), | |
80 | using the function's return value as the thread's exit status. | |
847e0d88 | 81 | .PP |
c495ab1b MK |
82 | To allow other threads to continue execution, |
83 | the main thread should terminate by calling | |
79bb6430 | 84 | .BR pthread_exit () |
c495ab1b MK |
85 | rather than |
86 | .BR exit (3). | |
847e0d88 | 87 | .PP |
c495ab1b | 88 | The value pointed to by |
1ae6b2c7 | 89 | .I retval |
c495ab1b MK |
90 | should not be located on the calling thread's stack, |
91 | since the contents of that stack are undefined after the thread terminates. | |
257f73f2 MK |
92 | .SH BUGS |
93 | Currently, | |
94 | .\" Linux 2.6.27 | |
95 | there are limitations in the kernel implementation logic for | |
96 | .BR wait (2)ing | |
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 | |
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) |