pthread_detach() — mark a thread as detached to reclaim its resources when it terminates
DESCRIPTION
pthread_detach() is used to detach the thread thread. When thread terminates, its resources will automatically be reclaimed by the system. If thread has already terminated, pthread_detach() causes the resources of thread to be reclaimed by the system.
pthread_detach() does not cause thread to terminate.
Once a detached thread has terminated, its resources, including the thread ID, may be reused by the system. The return status of a detached thread is lost when the thread terminates.
Calling this function multiple times for the same thread results in undefined behavior.
RETURN VALUE
Upon successful completion, pthread_detach() returns zero. Otherwise, an error number is returned to indicate the error (the errno variable is not set).