pthread_detach(3T) DG/UX R4.11MU05 pthread_detach(3T)
NAME
pthreaddetach - detach a thread
SYNOPSIS
#include <pthread.h>
int pthreaddetach(pthreadt *thread);
where:
thread A pointer to the thread ID of the target thread
DESCRIPTION
The pthreaddetach() function indicates to the system that the
storage for the thread whose thread ID is in the location pointed to
by thread can be reclaimed when that thread terminates.
If thread has not terminated, pthreaddetach() will not cause it to
terminate. pthreaddetach() may set the location referenced by
thread to an defined invalid value.
Joins of a detached thread will wake up with an ESRCH error. When
pthreadjoin() returns successfully, the target has been detached; a
subsequent call to pthreaddetach() is unnecessary and, in fact, is
dangerous.
DIAGNOSTICS
Returns
If successful, pthreaddetach() returns 0. Otherwise it returns -1
and sets errno to indicate the error.
Errors
For each of the following conditions, pthreaddetach() returns -1 and
sets errno to the corresponding value:
[EINVAL] The value specified by thread is invalid or does not refer
to an existing thread.
[ESRCH] The value specified by thread refers to a thread that is
already detached.
SEE ALSO
pthreadcreate(3T), pthreadjoin(3T), pthreadexit(3T),
pthreadattrsetdetachstate(3T).
NOTES
This call is being phased out of Posix 1003.4a. It will likely not
make it into the final standard. Hence applications should avoid
using this call for reasons of maximizing future portability.
In any case, it is more efficient to create a thread as detached
using pthreadattrsetdetachstate() than to detach a thread after it
has been created. This probably explains why pthreaddetach() will
likely be phased out.
Once a detached thread exits, the application should take great care
not to continue to use the thread's ID, as the system may quickly
reuse the thread and its ID. For example, it is dangerous to call
pthreaddetach() on a thread that has been successfully joined, and
vice-versa.
Licensed material--property of copyright holder(s)