]>
Commit | Line | Data |
---|---|---|
4b5ce6c3 MK |
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
4b5ce6c3 MK |
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. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
4b5ce6c3 | 25 | .\" |
4b8c67d9 | 26 | .TH PTHREAD_ATTR_SETDETACHSTATE 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
4b5ce6c3 MK |
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> | |
dbfe9c70 | 33 | .PP |
4b5ce6c3 MK |
34 | .BI "int pthread_attr_setdetachstate(pthread_attr_t *" attr \ |
35 | ", int " detachstate ); | |
e59f5f58 | 36 | .BI "int pthread_attr_getdetachstate(const pthread_attr_t *" attr \ |
4b5ce6c3 | 37 | ", int *" detachstate ); |
68e4db0a | 38 | .PP |
4b5ce6c3 | 39 | Compile and link with \fI\-pthread\fP. |
6030f2d8 | 40 | .fi |
4b5ce6c3 MK |
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 | |
3ab624b6 | 46 | .IR attr |
4b5ce6c3 MK |
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. | |
847e0d88 | 53 | .PP |
c5571b61 | 54 | The following values may be specified in |
4b5ce6c3 MK |
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 . | |
847e0d88 | 70 | .PP |
4b5ce6c3 MK |
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; | |
c7094399 | 79 | on error, they return a nonzero error number. |
4b5ce6c3 | 80 | .SH ERRORS |
27d47e71 | 81 | .BR pthread_attr_setdetachstate () |
4b5ce6c3 MK |
82 | can fail with the following error: |
83 | .TP | |
84 | .B EINVAL | |
85 | An invalid value was specified in | |
86 | .IR detachstate . | |
681f627e | 87 | .SH ATTRIBUTES |
cca0e0ae PH |
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 (), | |
681f627e | 97 | .BR pthread_attr_getdetachstate () |
cca0e0ae PH |
98 | T} Thread safety MT-Safe |
99 | .TE | |
4b5ce6c3 | 100 | .SH CONFORMING TO |
d0a20476 | 101 | POSIX.1-2001, POSIX.1-2008. |
4b5ce6c3 MK |
102 | .SH NOTES |
103 | See | |
104 | .BR pthread_create (3) | |
105 | for more details on detached and joinable threads. | |
847e0d88 | 106 | .PP |
4b5ce6c3 MK |
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). | |
847e0d88 | 114 | .PP |
c5571b61 | 115 | It is an error to specify the thread ID of |
4b5ce6c3 MK |
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) |