]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_exit.3
Changes: sync
[thirdparty/man-pages.git] / man3 / pthread_exit.3
CommitLineData
c495ab1b
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
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.
7.\"
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.
12.\"
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
19.\" professionally.
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\"
79bb6430 24.TH PTHREAD_EXIT 3 2009-03-30 "Linux" "Linux Programmer's Manual"
c495ab1b
MK
25.SH NAME
26pthread_exit \- terminate calling thread
27.SH SYNOPSIS
28.nf
29.B #include <pthread.h>
30
87d68647 31.BI "void pthread_exit(void *" retval );
c495ab1b
MK
32.sp
33Compile and link with \fI\-pthread\fP.
34.SH DESCRIPTION
35The
36.BR pthread_exit ()
37function terminates the calling thread and returns a value via
38.I retval
39that (if the thread is joinable)
40is available to another thread in the same process that calls
41.BR pthread_join (3).
42
43Any clean-up handlers established by
44.BR pthread_cleanup_push (3)
45that have not yet been popped,
46are popped (in the reverse of the order in which they were pushed)
47and executed.
48If the thread has any thread-specific data, then,
49after the clean-up handlers have been executed,
50the corresponding destructor functions are called,
51in an unspecified order.
52
53When a thread terminates,
54process-shared resources (e.g., mutexes, condition variables,
55semaphores, and file descriptors) are not released,
56and functions registered using
57.BR atexit (3)
58are not called.
59
60After the last thread in a process terminates,
61the process terminates as by calling
62.BR exit (3)
63with an exit status of zero;
64thus, process-shared resources
65are released and functions registered using
66.BR atexit (3)
67are called.
68.SH RETURN VALUE
69This function does not return to the caller.
70.SH ERRORS
71This function always succeeds.
72.SH CONFORMING TO
73POSIX.1-2001.
74.SH NOTES
75Performing a return from the start function of any thread other
76than the main thread results in an implicit call to
77.BR pthread_exit (),
78using the function's return value as the thread's exit status.
79
80To allow other threads to continue execution,
81the main thread should terminate by calling
79bb6430 82.BR pthread_exit ()
c495ab1b
MK
83rather than
84.BR exit (3).
85
86The value pointed to by
87.IR retval
88should not be located on the calling thread's stack,
89since the contents of that stack are undefined after the thread terminates.
257f73f2
MK
90.SH BUGS
91Currently,
92.\" Linux 2.6.27
93there are limitations in the kernel implementation logic for
94.BR wait (2)ing
95on a stopped thread group with a dead thread group leader.
96This can manifest in problems such as a locked terminal if a stop signal is
97sent to a foreground process whose thread group leader has already called
98.BR pthread_exit (3).
99.\" FIXME . review a later kernel to see if this gets fixed
100.\" http://thread.gmane.org/gmane.linux.kernel/611611
101.\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
c495ab1b
MK
102.SH SEE ALSO
103.BR pthread_create (3),
104.BR pthread_join (3),
105.BR pthreads (7)