1PTHREAD_EXIT(3P)           POSIX Programmer's Manual          PTHREAD_EXIT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       pthread_exit — thread termination
13

SYNOPSIS

15       #include <pthread.h>
16
17       void pthread_exit(void *value_ptr);
18

DESCRIPTION

20       The pthread_exit() function shall terminate the calling thread and make
21       the value value_ptr available to any successful join with the terminat‐
22       ing thread. Any cancellation cleanup handlers that have been pushed and
23       not  yet  popped  shall  be  popped in the reverse order that they were
24       pushed and then executed. After all cancellation cleanup handlers  have
25       been  executed, if the thread has any thread-specific data, appropriate
26       destructor functions shall be called in an  unspecified  order.  Thread
27       termination does not release any application visible process resources,
28       including, but not limited to, mutexes and file descriptors,  nor  does
29       it  perform  any process-level cleanup actions, including, but not lim‐
30       ited to, calling any atexit() routines that may exist.
31
32       An implicit call to pthread_exit() is made when a thread other than the
33       thread in which main() was first invoked returns from the start routine
34       that was used to create it. The function's return value shall serve  as
35       the thread's exit status.
36
37       The  behavior of pthread_exit() is undefined if called from a cancella‐
38       tion cleanup handler or destructor  function  that  was  invoked  as  a
39       result of either an implicit or explicit call to pthread_exit().
40
41       After  a  thread  has  terminated, the result of access to local (auto)
42       variables of the thread is undefined. Thus, references to  local  vari‐
43       ables  of  the exiting thread should not be used for the pthread_exit()
44       value_ptr parameter value.
45
46       The process shall exit with an exit status of 0 after the  last  thread
47       has  been  terminated.  The  behavior shall be as if the implementation
48       called exit() with a zero argument at thread termination time.
49

RETURN VALUE

51       The pthread_exit() function cannot return to its caller.
52

ERRORS

54       No errors are defined.
55
56       The following sections are informative.
57

EXAMPLES

59       None.
60

APPLICATION USAGE

62       None.
63

RATIONALE

65       The normal mechanism by which a thread terminates is to return from the
66       routine  that  was  specified in the pthread_create() call that started
67       it. The pthread_exit() function provides the capability for a thread to
68       terminate  without  requiring  a  return from the start routine of that
69       thread, thereby providing a function analogous to exit().
70
71       Regardless of  the  method  of  thread  termination,  any  cancellation
72       cleanup handlers that have been pushed and not yet popped are executed,
73       and the destructors for any existing thread-specific data are executed.
74       This volume of POSIX.1‐2017 requires that cancellation cleanup handlers
75       be popped and called in order. After all cancellation cleanup  handlers
76       have  been executed, thread-specific data destructors are called, in an
77       unspecified order, for each item of thread-specific data that exists in
78       the  thread.  This  ordering  is necessary because cancellation cleanup
79       handlers may rely on thread-specific data.
80
81       As the meaning of the status is determined by the  application  (except
82       when  the  thread  has  been canceled, in which case it is PTHREAD_CAN‐
83       CELED), the implementation has no idea what an illegal status value is,
84       which is why no address error checking is done.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       exit(), pthread_create(), pthread_join()
91
92       The Base Definitions volume of POSIX.1‐2017, <pthread.h>
93
95       Portions  of  this text are reprinted and reproduced in electronic form
96       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
97       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
98       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
99       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
100       event of any discrepancy between this version and the original IEEE and
101       The  Open Group Standard, the original IEEE and The Open Group Standard
102       is the referee document. The original Standard can be  obtained  online
103       at http://www.opengroup.org/unix/online.html .
104
105       Any  typographical  or  formatting  errors that appear in this page are
106       most likely to have been introduced during the conversion of the source
107       files  to  man page format. To report such errors, see https://www.ker
108       nel.org/doc/man-pages/reporting_bugs.html .
109
110
111
112IEEE/The Open Group                  2017                     PTHREAD_EXIT(3P)
Impressum