Test for stack alignment.
[glibc.git] / linuxthreads / man / pthread_detach.man
blob7b43f45faa513df93fdcc1bb25d04dd6810eb8a2
1 .TH PTHREAD_DETACH 3 LinuxThreads
3 .SH NAME
4 pthread_detach \- put a running thread in the detached state
6 .SH SYNOPSIS
7 #include <pthread.h>
9 int pthread_detach(pthread_t th);
11 .SH DESCRIPTION
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.
27 .SH "RETURN VALUE"
28 On success, 0 is returned. On error, a non-zero error code is returned.
30 .SH ERRORS
31 .TP
32 !ESRCH!
33 No thread could be found corresponding to that specified by |th|
34 .TP
35 !EINVAL!
36 the thread |th| is already in the detached state
38 .SH AUTHOR
39 Xavier Leroy <Xavier.Leroy@inria.fr>
41 .SH "SEE ALSO"
42 !pthread_create!(3),
43 !pthread_join!(3),
44 !pthread_attr_setdetachstate!(3).