#include <pthread.h>
void pthread_exit(void *status);
#include <thread.h>
void thr_exit(void *status);
Upon thread termination, all thread-specific data bindings are released (see pthread_key_create(3T) ), and its cancellation routines are called, but application visible process resources, including, but not limited to, mutexes and file descriptors are not released.
The cleanup handlers are called before the thread-specific data bindings are released (see pthread_cancel(3T) ). Any cancellation cleanup handlers that have been pushed and not yet popped will be popped in reverse order of when they were pushed and then executed. If the thread still has any thread-specific data after all cancellation cleanup handlers have been executed, appropriate destructor functions will be called in an unspecified order. If any thread, including the main()thread, calls pthread_exit(), only that thread will exit.
If main() returns or exits (either implicitly or explicitly), or any thread explicitly calls exit(), the entire process will exit.
If any thread (except the main() thread) implicitly or explicitly returns, the result is the same as if the thread called pthread_exit() and it will return the value of status as the exit code.
The process will terminate with an exit status of 0 after the last thread has terminated (including the main() thread). This action is the same as if the application had called exit() with a zero argument at any time.
Do not call pthread_exit() from a cancellation cleanup handler or destructor function that will be invoked as a result of either an implicit or explicit call to pthread_exit().
status should not reference any variables local to the calling thread.