]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/pthread_attr_setdetachstate.3
signal.7: Note async-signal-safe functions added by POSIX.1-2008 TC1
[thirdparty/man-pages.git] / man3 / pthread_attr_setdetachstate.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH PTHREAD_ATTR_SETDETACHSTATE 3 2015-08-08 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
29 set/get detach state attribute in thread attributes object
30 .SH SYNOPSIS
31 .nf
32 .B #include <pthread.h>
33
34 .BI "int pthread_attr_setdetachstate(pthread_attr_t *" attr \
35 ", int " detachstate );
36 .BI "int pthread_attr_getdetachstate(const pthread_attr_t *" attr \
37 ", int *" detachstate );
38 .sp
39 Compile and link with \fI\-pthread\fP.
40 .fi
41 .SH DESCRIPTION
42 The
43 .BR pthread_attr_setdetachstate ()
44 function sets the detach state attribute of the
45 thread attributes object referred to by
46 .IR attr
47 to the value specified in
48 .IR detachstate .
49 The detach state attribute determines whether a thread created using
50 the thread attributes object
51 .I attr
52 will be created in a joinable or a detached state.
53
54 The following values may be specified in
55 .IR detachstate :
56 .TP
57 .B PTHREAD_CREATE_DETACHED
58 Threads that are created using
59 .I attr
60 will be created in a detached state.
61 .TP
62 .B PTHREAD_CREATE_JOINABLE
63 Threads that are created using
64 .I attr
65 will be created in a joinable state.
66 .PP
67 The default setting of the detach state attribute in a newly initialized
68 thread attributes object is
69 .BR PTHREAD_CREATE_JOINABLE .
70
71 The
72 .BR pthread_attr_getdetachstate ()
73 returns the detach state attribute of the thread attributes object
74 .IR attr
75 in the buffer pointed to by
76 .IR detachstate .
77 .SH RETURN VALUE
78 On success, these functions return 0;
79 on error, they return a nonzero error number.
80 .SH ERRORS
81 .BR pthread_attr_setdetachstate ()
82 can fail with the following error:
83 .TP
84 .B EINVAL
85 An invalid value was specified in
86 .IR detachstate .
87 .SH ATTRIBUTES
88 For an explanation of the terms used in this section, see
89 .BR attributes (7).
90 .TS
91 allbox;
92 lbw30 lb lb
93 l l l.
94 Interface Attribute Value
95 T{
96 .BR pthread_attr_setdetachstate (),
97 .BR pthread_attr_getdetachstate ()
98 T} Thread safety MT-Safe
99 .TE
100 .SH CONFORMING TO
101 POSIX.1-2001, POSIX.1-2008.
102 .SH NOTES
103 See
104 .BR pthread_create (3)
105 for more details on detached and joinable threads.
106
107 A thread that is created in a joinable state should
108 eventually either be joined using
109 .BR pthread_join (3)
110 or detached using
111 .BR pthread_detach (3);
112 see
113 .BR pthread_create (3).
114
115 It is an error to specify the thread ID of
116 a thread that was created in a detached state
117 in a later call to
118 .BR pthread_detach (3)
119 or
120 .BR pthread_join (3).
121 .SH EXAMPLE
122 See
123 .BR pthread_attr_init (3).
124 .SH SEE ALSO
125 .BR pthread_attr_init (3),
126 .BR pthread_create (3),
127 .BR pthread_detach (3),
128 .BR pthread_join (3),
129 .BR pthreads (7)