]>
Commit | Line | Data |
---|---|---|
4b5ce6c3 MK |
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
4b5ce6c3 | 5 | .\" |
45186a5d | 6 | .TH PTHREAD_ATTR_SETDETACHSTATE 3 2021-03-22 "Linux man-pages (unreleased)" |
4b5ce6c3 MK |
7 | .SH NAME |
8 | pthread_attr_setdetachstate, pthread_attr_getdetachstate \- | |
9 | set/get detach state attribute in thread attributes object | |
ceb11b84 AC |
10 | .SH LIBRARY |
11 | POSIX threads library | |
8fc3b2cf | 12 | .RI ( libpthread ", " \-lpthread ) |
4b5ce6c3 MK |
13 | .SH SYNOPSIS |
14 | .nf | |
15 | .B #include <pthread.h> | |
dbfe9c70 | 16 | .PP |
4b5ce6c3 MK |
17 | .BI "int pthread_attr_setdetachstate(pthread_attr_t *" attr \ |
18 | ", int " detachstate ); | |
3bf92061 MK |
19 | .BI "int pthread_attr_getdetachstate(const pthread_attr_t *" attr , |
20 | .BI " int *" detachstate ); | |
6030f2d8 | 21 | .fi |
4b5ce6c3 MK |
22 | .SH DESCRIPTION |
23 | The | |
24 | .BR pthread_attr_setdetachstate () | |
25 | function sets the detach state attribute of the | |
26 | thread attributes object referred to by | |
1ae6b2c7 | 27 | .I attr |
4b5ce6c3 MK |
28 | to the value specified in |
29 | .IR detachstate . | |
30 | The detach state attribute determines whether a thread created using | |
31 | the thread attributes object | |
32 | .I attr | |
33 | will be created in a joinable or a detached state. | |
847e0d88 | 34 | .PP |
c5571b61 | 35 | The following values may be specified in |
4b5ce6c3 MK |
36 | .IR detachstate : |
37 | .TP | |
38 | .B PTHREAD_CREATE_DETACHED | |
39 | Threads that are created using | |
40 | .I attr | |
41 | will be created in a detached state. | |
42 | .TP | |
43 | .B PTHREAD_CREATE_JOINABLE | |
44 | Threads that are created using | |
45 | .I attr | |
46 | will be created in a joinable state. | |
47 | .PP | |
48 | The default setting of the detach state attribute in a newly initialized | |
49 | thread attributes object is | |
50 | .BR PTHREAD_CREATE_JOINABLE . | |
847e0d88 | 51 | .PP |
4b5ce6c3 MK |
52 | The |
53 | .BR pthread_attr_getdetachstate () | |
54 | returns the detach state attribute of the thread attributes object | |
1ae6b2c7 | 55 | .I attr |
4b5ce6c3 MK |
56 | in the buffer pointed to by |
57 | .IR detachstate . | |
58 | .SH RETURN VALUE | |
59 | On success, these functions return 0; | |
c7094399 | 60 | on error, they return a nonzero error number. |
4b5ce6c3 | 61 | .SH ERRORS |
27d47e71 | 62 | .BR pthread_attr_setdetachstate () |
4b5ce6c3 MK |
63 | can fail with the following error: |
64 | .TP | |
65 | .B EINVAL | |
66 | An invalid value was specified in | |
67 | .IR detachstate . | |
681f627e | 68 | .SH ATTRIBUTES |
cca0e0ae PH |
69 | For an explanation of the terms used in this section, see |
70 | .BR attributes (7). | |
c466875e MK |
71 | .ad l |
72 | .nh | |
cca0e0ae PH |
73 | .TS |
74 | allbox; | |
c466875e | 75 | lbx lb lb |
cca0e0ae PH |
76 | l l l. |
77 | Interface Attribute Value | |
78 | T{ | |
79 | .BR pthread_attr_setdetachstate (), | |
681f627e | 80 | .BR pthread_attr_getdetachstate () |
cca0e0ae PH |
81 | T} Thread safety MT-Safe |
82 | .TE | |
c466875e MK |
83 | .hy |
84 | .ad | |
85 | .sp 1 | |
3113c7f3 | 86 | .SH STANDARDS |
d0a20476 | 87 | POSIX.1-2001, POSIX.1-2008. |
4b5ce6c3 MK |
88 | .SH NOTES |
89 | See | |
90 | .BR pthread_create (3) | |
91 | for more details on detached and joinable threads. | |
847e0d88 | 92 | .PP |
4b5ce6c3 MK |
93 | A thread that is created in a joinable state should |
94 | eventually either be joined using | |
95 | .BR pthread_join (3) | |
96 | or detached using | |
97 | .BR pthread_detach (3); | |
98 | see | |
99 | .BR pthread_create (3). | |
847e0d88 | 100 | .PP |
c5571b61 | 101 | It is an error to specify the thread ID of |
4b5ce6c3 MK |
102 | a thread that was created in a detached state |
103 | in a later call to | |
104 | .BR pthread_detach (3) | |
105 | or | |
106 | .BR pthread_join (3). | |
a14af333 | 107 | .SH EXAMPLES |
4b5ce6c3 MK |
108 | See |
109 | .BR pthread_attr_init (3). | |
110 | .SH SEE ALSO | |
111 | .BR pthread_attr_init (3), | |
112 | .BR pthread_create (3), | |
113 | .BR pthread_detach (3), | |
114 | .BR pthread_join (3), | |
115 | .BR pthreads (7) |