1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .TH PTHREAD_EXIT 3 2009-03-30 "Linux" "Linux Programmer's Manual"
26 pthread_exit \- terminate calling thread
29 .B #include <pthread.h>
31 .BI "void pthread_exit(void *" retval );
33 Compile and link with \fI\-pthread\fP.
38 function terminates the calling thread and returns a value via
40 that (if the thread is joinable)
41 is available to another thread in the same process that calls
44 Any clean-up handlers established by
45 .BR pthread_cleanup_push (3)
46 that have not yet been popped,
47 are popped (in the reverse of the order in which they were pushed)
49 If the thread has any thread-specific data, then,
50 after the clean-up handlers have been executed,
51 the corresponding destructor functions are called,
52 in an unspecified order.
54 When a thread terminates,
55 process-shared resources (e.g., mutexes, condition variables,
56 semaphores, and file descriptors) are not released,
57 and functions registered using
61 After the last thread in a process terminates,
62 the process terminates as by calling
64 with an exit status of zero;
65 thus, process-shared resources
66 are released and functions registered using
70 This function does not return to the caller.
72 This function always succeeds.
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),