OSDN Git Service

5b5c1ff25b48a6f0ed1dc274c66c1930d2ed6c94
[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 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_ATTR_SETDETACHSTATE 3 2010-02-03 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_attr_setdetachstate, pthread_attr_getdetachstate \-
27 set/get detach state attribute in thread attributes object
28 .SH SYNOPSIS
29 .nf
30 .B #include <pthread.h>
31
32 .BI "int pthread_attr_setdetachstate(pthread_attr_t *" attr \
33 ", int " detachstate );
34 .BI "int pthread_attr_getdetachstate(pthread_attr_t *" attr \
35 ", int *" detachstate );
36 .sp
37 Compile and link with \fI\-pthread\fP.
38 .SH DESCRIPTION
39 The
40 .BR pthread_attr_setdetachstate ()
41 function sets the detach state attribute of the
42 thread attributes object referred to by
43 .IR attr
44 to the value specified in
45 .IR detachstate .
46 The detach state attribute determines whether a thread created using
47 the thread attributes object
48 .I attr
49 will be created in a joinable or a detached state.
50
51 The following values may be specified in
52 .IR detachstate :
53 .TP
54 .B PTHREAD_CREATE_DETACHED
55 Threads that are created using
56 .I attr
57 will be created in a detached state.
58 .TP
59 .B PTHREAD_CREATE_JOINABLE
60 Threads that are created using
61 .I attr
62 will be created in a joinable state.
63 .PP
64 The default setting of the detach state attribute in a newly initialized
65 thread attributes object is
66 .BR PTHREAD_CREATE_JOINABLE .
67
68 The
69 .BR pthread_attr_getdetachstate ()
70 returns the detach state attribute of the thread attributes object
71 .IR attr
72 in the buffer pointed to by
73 .IR detachstate .
74 .SH RETURN VALUE
75 On success, these functions return 0;
76 on error, they return a nonzero error number.
77 .SH ERRORS
78 .BR pthread_attr_setdetachstate ()
79 can fail with the following error:
80 .TP
81 .B EINVAL
82 An invalid value was specified in
83 .IR detachstate .
84 .SH CONFORMING TO
85 POSIX.1-2001.
86 .SH NOTES
87 See
88 .BR pthread_create (3)
89 for more details on detached and joinable threads.
90
91 A thread that is created in a joinable state should
92 eventually either be joined using
93 .BR pthread_join (3)
94 or detached using
95 .BR pthread_detach (3);
96 see
97 .BR pthread_create (3).
98
99 It is an error to specify the thread ID of
100 a thread that was created in a detached state
101 in a later call to
102 .BR pthread_detach (3)
103 or
104 .BR pthread_join (3).
105 .SH EXAMPLE
106 See
107 .BR pthread_attr_init (3).
108 .SH SEE ALSO
109 .BR pthread_attr_init (3),
110 .BR pthread_create (3),
111 .BR pthread_detach (3),
112 .BR pthread_join (3),
113 .BR pthreads (7)