1PTHREAD_EXIT(3)            Linux Programmer's Manual           PTHREAD_EXIT(3)
2
3
4

NAME

6       pthread_exit - terminate calling thread
7

SYNOPSIS

9       #include <pthread.h>
10
11       void pthread_exit(void *retval);
12
13       Compile and link with -pthread.
14

DESCRIPTION

16       The pthread_exit() function terminates the calling thread and returns a
17       value via retval that (if the  thread  is  joinable)  is  available  to
18       another thread in the same process that calls pthread_join(3).
19
20       Any  clean-up handlers established by pthread_cleanup_push(3) that have
21       not yet been popped, are popped (in the reverse of the order  in  which
22       they  were pushed) and executed.  If the thread has any thread-specific
23       data, then, after the clean-up handlers have been executed, the  corre‐
24       sponding destructor functions are called, in an unspecified order.
25
26       When a thread terminates, process-shared resources (e.g., mutexes, con‐
27       dition variables, semaphores, and file descriptors) are  not  released,
28       and functions registered using atexit(3) are not called.
29
30       After  the  last thread in a process terminates, the process terminates
31       as by calling exit(3) with an exit status of zero; thus, process-shared
32       resources  are  released  and  functions registered using atexit(3) are
33       called.
34

RETURN VALUE

36       This function does not return to the caller.
37

ERRORS

39       This function always succeeds.
40

CONFORMING TO

42       POSIX.1-2001.
43

NOTES

45       Performing a return from the start function of any  thread  other  than
46       the  main  thread  results in an implicit call to pthread_exit(), using
47       the function's return value as the thread's exit status.
48
49       To allow other threads to continue execution, the  main  thread  should
50       terminate by calling pthread_exit() rather than exit(3).
51
52       The  value  pointed  to  by retval should not be located on the calling
53       thread's stack, since the contents of that stack  are  undefined  after
54       the thread terminates.
55

BUGS

57       Currently, there are limitations in the kernel implementation logic for
58       wait(2)ing on a stopped thread group with a dead thread  group  leader.
59       This  can manifest in problems such as a locked terminal if a stop sig‐
60       nal is sent to a foreground  process  whose  thread  group  leader  has
61       already called pthread_exit().
62

SEE ALSO

64       pthread_create(3), pthread_join(3), pthreads(7)
65

COLOPHON

67       This  page  is  part of release 3.53 of the Linux man-pages project.  A
68       description of the project, and information about reporting  bugs,  can
69       be found at http://www.kernel.org/doc/man-pages/.
70
71
72
73Linux                             2009-03-30                   PTHREAD_EXIT(3)
Impressum