]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_attr_setdetachstate.3
fuse.4: fuse_entry_out: rework discussion of uniqueness of nodeid + generation
[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.\"
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.\"
460495ca 26.TH PTHREAD_ATTR_SETDETACHSTATE 3 2015-08-08 "Linux" "Linux Programmer's Manual"
4b5ce6c3
MK
27.SH NAME
28pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
29set/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 );
e59f5f58 36.BI "int pthread_attr_getdetachstate(const pthread_attr_t *" attr \
4b5ce6c3
MK
37", int *" detachstate );
38.sp
39Compile and link with \fI\-pthread\fP.
6030f2d8 40.fi
4b5ce6c3
MK
41.SH DESCRIPTION
42The
43.BR pthread_attr_setdetachstate ()
44function sets the detach state attribute of the
45thread attributes object referred to by
3ab624b6 46.IR attr
4b5ce6c3
MK
47to the value specified in
48.IR detachstate .
49The detach state attribute determines whether a thread created using
50the thread attributes object
51.I attr
52will be created in a joinable or a detached state.
53
c5571b61 54The following values may be specified in
4b5ce6c3
MK
55.IR detachstate :
56.TP
57.B PTHREAD_CREATE_DETACHED
58Threads that are created using
59.I attr
60will be created in a detached state.
61.TP
62.B PTHREAD_CREATE_JOINABLE
63Threads that are created using
64.I attr
65will be created in a joinable state.
66.PP
67The default setting of the detach state attribute in a newly initialized
68thread attributes object is
69.BR PTHREAD_CREATE_JOINABLE .
70
71The
72.BR pthread_attr_getdetachstate ()
73returns the detach state attribute of the thread attributes object
74.IR attr
75in the buffer pointed to by
76.IR detachstate .
77.SH RETURN VALUE
78On success, these functions return 0;
c7094399 79on error, they return a nonzero error number.
4b5ce6c3 80.SH ERRORS
27d47e71 81.BR pthread_attr_setdetachstate ()
4b5ce6c3
MK
82can fail with the following error:
83.TP
84.B EINVAL
85An invalid value was specified in
86.IR detachstate .
681f627e 87.SH ATTRIBUTES
cca0e0ae
PH
88For an explanation of the terms used in this section, see
89.BR attributes (7).
90.TS
91allbox;
92lbw30 lb lb
93l l l.
94Interface Attribute Value
95T{
96.BR pthread_attr_setdetachstate (),
681f627e 97.BR pthread_attr_getdetachstate ()
cca0e0ae
PH
98T} Thread safety MT-Safe
99.TE
4b5ce6c3 100.SH CONFORMING TO
d0a20476 101POSIX.1-2001, POSIX.1-2008.
4b5ce6c3
MK
102.SH NOTES
103See
104.BR pthread_create (3)
105for more details on detached and joinable threads.
106
107A thread that is created in a joinable state should
108eventually either be joined using
109.BR pthread_join (3)
110or detached using
111.BR pthread_detach (3);
112see
113.BR pthread_create (3).
114
c5571b61 115It is an error to specify the thread ID of
4b5ce6c3
MK
116a thread that was created in a detached state
117in a later call to
118.BR pthread_detach (3)
119or
120.BR pthread_join (3).
121.SH EXAMPLE
122See
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)