Marks a thread object for deletion.
1 – C Binding
#include <pthread.h> int pthread_detach ( pthread_t thread);
2 – Arguments
thread Thread object being marked for deletion.
3 – Description
This routine marks the specified thread object to indicate that storage for the corresponding thread can be reclaimed when the thread terminates. This includes storage for the thread argument's return value, as well as the thread object. If thread has not terminated when this routine is called, this routine does not cause it to terminate. When a thread object is no longer referenced, call this routine. The results of this routine are unpredictable if the value of thread refers to a thread object that does not exist. You can create a thread already detached by setting its thread object's detachstate attribute. The pthread_join() routine also detaches the target thread after pthread_join() returns successfully.
4 – Return Values
If an error condition occurs, this routine returns an integer indicating the type of error. Possible return values are as follows: Return Description 0 Successful completion. [EINVAL] The value specified by thread does not refer to a joinable thread. [ESRCH] The value specified by thread cannot be found.
5 – Associated Routines
pthread_cancel() pthread_create() pthread_exit() pthread_join()