1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .TH PTHREAD_ATTR_SETDETACHSTATE 3 2010-02-03 "Linux" "Linux Programmer's Manual"
26 pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
27 set/get detach state attribute in thread attributes object
30 .B #include <pthread.h>
32 .BI "int pthread_attr_setdetachstate(pthread_attr_t *" attr \
33 ", int " detachstate );
34 .BI "int pthread_attr_getdetachstate(pthread_attr_t *" attr \
35 ", int *" detachstate );
37 Compile and link with \fI\-pthread\fP.
40 .BR pthread_attr_setdetachstate ()
41 function sets the detach state attribute of the
42 thread attributes object referred to by
44 to the value specified in
46 The detach state attribute determines whether a thread created using
47 the thread attributes object
49 will be created in a joinable or a detached state.
51 The following values may be specified in
54 .B PTHREAD_CREATE_DETACHED
55 Threads that are created using
57 will be created in a detached state.
59 .B PTHREAD_CREATE_JOINABLE
60 Threads that are created using
62 will be created in a joinable state.
64 The default setting of the detach state attribute in a newly initialized
65 thread attributes object is
66 .BR PTHREAD_CREATE_JOINABLE .
69 .BR pthread_attr_getdetachstate ()
70 returns the detach state attribute of the thread attributes object
72 in the buffer pointed to by
75 On success, these functions return 0;
76 on error, they return a nonzero error number.
78 .BR pthread_attr_setdetachstate ()
79 can fail with the following error:
82 An invalid value was specified in
88 .BR pthread_create (3)
89 for more details on detached and joinable threads.
91 A thread that is created in a joinable state should
92 eventually either be joined using
95 .BR pthread_detach (3);
97 .BR pthread_create (3).
99 It is an error to specify the thread ID of
100 a thread that was created in a detached state
102 .BR pthread_detach (3)
104 .BR pthread_join (3).
107 .BR pthread_attr_init (3).
109 .BR pthread_attr_init (3),
110 .BR pthread_create (3),
111 .BR pthread_detach (3),
112 .BR pthread_join (3),