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

NAME

6       pthread_exit - thread termination
7

SYNOPSIS

9       #include <pthread.h>
10
11       void pthread_exit(void *value_ptr);
12
13

DESCRIPTION

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

RETURN VALUE

46       The pthread_exit() function cannot return to its caller.
47

ERRORS

49       No errors are defined.
50
51       The following sections are informative.
52

EXAMPLES

54       None.
55

APPLICATION USAGE

57       None.
58

RATIONALE

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

FUTURE DIRECTIONS

82       None.
83

SEE ALSO

85       exit() , pthread_create() , pthread_join() , the Base Definitions  vol‐
86       ume of IEEE Std 1003.1-2001, <pthread.h>
87
89       Portions  of  this text are reprinted and reproduced in electronic form
90       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
91       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
92       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
93       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
94       event of any discrepancy between this version and the original IEEE and
95       The  Open Group Standard, the original IEEE and The Open Group Standard
96       is the referee document. The original Standard can be  obtained  online
97       at http://www.opengroup.org/unix/online.html .
98
99
100
101IEEE/The Open Group                  2003                      PTHREAD_EXIT(P)
Impressum