1 .TH PTHREAD_DETACH 3 LinuxThreads
4 pthread_detach \- put a running thread in the detached state
9 int pthread_detach(pthread_t th);
12 !pthread_detach! put the thread |th| in the detached state. This
13 guarantees that the memory resources consumed by |th| will be freed
14 immediately when |th| terminates. However, this prevents other threads
15 from synchronizing on the termination of |th| using !pthread_join!.
17 A thread can be created initially in the detached state, using the
18 !detachstate! attribute to !pthread_create!(3). In contrast,
19 !pthread_detach! applies to threads created in the joinable state, and
20 which need to be put in the detached state later.
22 After !pthread_detach! completes, subsequent attempts to perform
23 !pthread_join! on |th| will fail. If another thread is already joining
24 the thread |th| at the time !pthread_detach! is called,
25 !pthread_detach! does nothing and leaves |th| in the joinable state.
28 On success, 0 is returned. On error, a non-zero error code is returned.
33 No thread could be found corresponding to that specified by |th|
36 the thread |th| is already in the detached state
39 Xavier Leroy <Xavier.Leroy@inria.fr>
44 !pthread_attr_setdetachstate!(3).