Changes the detachstate attribute of thread creation.
pthread_attr_setdetach_np(pthread_attr_t *attr, int detachstate);
Argument Data Type Accessattr opaque pthread_attr_t read detachstate integer read
int pthread_attr_setdetach_np ( pthread_attr_t *attr, int detachstate);
PTHREAD_CREATE_ This is the default value. Threads are created JOINABLE in "undetached" state. PTHREAD_CREATE_ The created thread is detached immediately, DETACHED before it begins running.
You cannot use the thread handle (the value of type thread_t that is returned by pthread_create) for a detached thread. This means that you cannot cancel the thread with pthread_cancel. You also cannot use pthread_join to wait for the thread to complete or to retrieve the thread's return status.
When a thread that has not been detached completes execution, DECthreads will retain the state of that thread to allow another thread to join with it. If the thread is detached before it completes, DECthreads is free to immediately reclaim the thread's storage and resources. Failing to detach threads that have completed execution can result in wasting resources, so threads should be detached as soon as the program is done with them. If there is no need to use the thread's handle after creation, create the thread initially detached.
Return Error Description0 Successful completion. -1 [EINVAL] The value specified by the detachstate attribute is invalid. -1 [ESRCH] The value specified by attr does not refer to an existing thread attributes object.