![]() |
![]() |
![]() |
Terminate thread
#include <pthread.h> void pthread_exit( void* value_ptr );
libc
The pthread_exit() function terminates the calling thread. If the thread is joinable, the value value_ptr is made available to any thread joining the terminating thread (only one thread can get the return status). If the thread is detached, all system resources allocated to the thread are immediately reclaimed.
Before the thread is terminated, any cancellation cleanup handlers that have been pushed are popped and executed, and any thread specific data destructor functions are executed. Thread termination doesn't implicitly release any process resources such as mutexes or file descriptors, or perform any process cleanup actions such as calling atexit() handlers.
An implicit call to pthread_exit() is made when a thread other than the thread in which main() was first invoked returns from the start routine that was used to create it. The return value of the start routine is used as the thread's exit status. The last thread in a process will be the main() thread, which exits with main()'s return value.
The pthread_exit() function shouldn't be called from cancellation cleanup handlers or thread specific data destructor functions.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
atexit(), exit(), pthread_create(), pthread_cleanup_push(), pthread_cleanup_pop(), pthread_join(), ThreadDestroy().
![]() |
![]() |
![]() |