]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_attr_setdetachstate.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / pthread_attr_setdetachstate.3
CommitLineData
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.\"
4c1c5274 6.TH pthread_attr_setdetachstate 3 (date) "Linux man-pages (unreleased)"
4b5ce6c3
MK
7.SH NAME
8pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
9set/get detach state attribute in thread attributes object
ceb11b84
AC
10.SH LIBRARY
11POSIX 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
23The
24.BR pthread_attr_setdetachstate ()
25function sets the detach state attribute of the
26thread attributes object referred to by
1ae6b2c7 27.I attr
4b5ce6c3
MK
28to the value specified in
29.IR detachstate .
30The detach state attribute determines whether a thread created using
31the thread attributes object
32.I attr
33will be created in a joinable or a detached state.
847e0d88 34.PP
c5571b61 35The following values may be specified in
4b5ce6c3
MK
36.IR detachstate :
37.TP
38.B PTHREAD_CREATE_DETACHED
39Threads that are created using
40.I attr
41will be created in a detached state.
42.TP
43.B PTHREAD_CREATE_JOINABLE
44Threads that are created using
45.I attr
46will be created in a joinable state.
47.PP
48The default setting of the detach state attribute in a newly initialized
49thread attributes object is
50.BR PTHREAD_CREATE_JOINABLE .
847e0d88 51.PP
4b5ce6c3
MK
52The
53.BR pthread_attr_getdetachstate ()
54returns the detach state attribute of the thread attributes object
1ae6b2c7 55.I attr
4b5ce6c3
MK
56in the buffer pointed to by
57.IR detachstate .
58.SH RETURN VALUE
59On success, these functions return 0;
c7094399 60on error, they return a nonzero error number.
4b5ce6c3 61.SH ERRORS
27d47e71 62.BR pthread_attr_setdetachstate ()
4b5ce6c3
MK
63can fail with the following error:
64.TP
65.B EINVAL
66An invalid value was specified in
67.IR detachstate .
681f627e 68.SH ATTRIBUTES
cca0e0ae
PH
69For 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
74allbox;
c466875e 75lbx lb lb
cca0e0ae
PH
76l l l.
77Interface Attribute Value
78T{
79.BR pthread_attr_setdetachstate (),
681f627e 80.BR pthread_attr_getdetachstate ()
cca0e0ae
PH
81T} Thread safety MT-Safe
82.TE
c466875e
MK
83.hy
84.ad
85.sp 1
3113c7f3 86.SH STANDARDS
d0a20476 87POSIX.1-2001, POSIX.1-2008.
4b5ce6c3
MK
88.SH NOTES
89See
90.BR pthread_create (3)
91for more details on detached and joinable threads.
847e0d88 92.PP
4b5ce6c3
MK
93A thread that is created in a joinable state should
94eventually either be joined using
95.BR pthread_join (3)
96or detached using
97.BR pthread_detach (3);
98see
99.BR pthread_create (3).
847e0d88 100.PP
c5571b61 101It is an error to specify the thread ID of
4b5ce6c3
MK
102a thread that was created in a detached state
103in a later call to
104.BR pthread_detach (3)
105or
106.BR pthread_join (3).
a14af333 107.SH EXAMPLES
4b5ce6c3
MK
108See
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)