OSDN Git Service

e6cc4c869d1be09852e9ee73ad5a307e70fc9f13
[linuxjm/LDP_man-pages.git] / original / 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 2010-02-03 "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(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 CONFORMING TO
88 POSIX.1-2001.
89 .SH NOTES
90 See
91 .BR pthread_create (3)
92 for more details on detached and joinable threads.
93
94 A thread that is created in a joinable state should
95 eventually either be joined using
96 .BR pthread_join (3)
97 or detached using
98 .BR pthread_detach (3);
99 see
100 .BR pthread_create (3).
101
102 It is an error to specify the thread ID of
103 a thread that was created in a detached state
104 in a later call to
105 .BR pthread_detach (3)
106 or
107 .BR pthread_join (3).
108 .SH EXAMPLE
109 See
110 .BR pthread_attr_init (3).
111 .SH SEE ALSO
112 .BR pthread_attr_init (3),
113 .BR pthread_create (3),
114 .BR pthread_detach (3),
115 .BR pthread_join (3),
116 .BR pthreads (7)
117 .SH COLOPHON
118 This page is part of release 3.64 of the Linux
119 .I man-pages
120 project.
121 A description of the project,
122 and information about reporting bugs,
123 can be found at
124 \%http://www.kernel.org/doc/man\-pages/.