OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_exit.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH PTHREAD_EXIT 3 2014-05-23 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 pthread_exit \- terminate calling thread
29 .SH SYNOPSIS
30 .nf
31 .B #include <pthread.h>
32
33 .BI "void pthread_exit(void *" retval );
34 .sp
35 Compile and link with \fI\-pthread\fP.
36 .fi
37 .SH DESCRIPTION
38 The
39 .BR pthread_exit ()
40 function terminates the calling thread and returns a value via
41 .I retval
42 that (if the thread is joinable)
43 is available to another thread in the same process that calls
44 .BR pthread_join (3).
45
46 Any clean-up handlers established by
47 .BR pthread_cleanup_push (3)
48 that have not yet been popped,
49 are popped (in the reverse of the order in which they were pushed)
50 and executed.
51 If the thread has any thread-specific data, then,
52 after the clean-up handlers have been executed,
53 the corresponding destructor functions are called,
54 in an unspecified order.
55
56 When a thread terminates,
57 process-shared resources (e.g., mutexes, condition variables,
58 semaphores, and file descriptors) are not released,
59 and functions registered using
60 .BR atexit (3)
61 are not called.
62
63 After the last thread in a process terminates,
64 the process terminates as by calling
65 .BR exit (3)
66 with an exit status of zero;
67 thus, process-shared resources
68 are released and functions registered using
69 .BR atexit (3)
70 are called.
71 .SH RETURN VALUE
72 This function does not return to the caller.
73 .SH ERRORS
74 This function always succeeds.
75 .SH ATTRIBUTES
76 .SS Multithreading (see pthreads(7))
77 The
78 .BR pthread_exit ()
79 function is thread-safe.
80 .SH CONFORMING TO
81 POSIX.1-2001.
82 .SH NOTES
83 Performing a return from the start function of any thread other
84 than the main thread results in an implicit call to
85 .BR pthread_exit (),
86 using the function's return value as the thread's exit status.
87
88 To allow other threads to continue execution,
89 the main thread should terminate by calling
90 .BR pthread_exit ()
91 rather than
92 .BR exit (3).
93
94 The value pointed to by
95 .IR retval
96 should not be located on the calling thread's stack,
97 since the contents of that stack are undefined after the thread terminates.
98 .SH BUGS
99 Currently,
100 .\" Linux 2.6.27
101 there are limitations in the kernel implementation logic for
102 .BR wait (2)ing
103 on a stopped thread group with a dead thread group leader.
104 This can manifest in problems such as a locked terminal if a stop signal is
105 sent to a foreground process whose thread group leader has already called
106 .BR pthread_exit ().
107 .\" FIXME . review a later kernel to see if this gets fixed
108 .\" http://thread.gmane.org/gmane.linux.kernel/611611
109 .\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
110 .SH SEE ALSO
111 .BR pthread_create (3),
112 .BR pthread_join (3),
113 .BR pthreads (7)
114 .SH COLOPHON
115 This page is part of release 3.79 of the Linux
116 .I man-pages
117 project.
118 A description of the project,
119 information about reporting bugs,
120 and the latest version of this page,
121 can be found at
122 \%http://www.kernel.org/doc/man\-pages/.