OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[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 .fi
39 .SH DESCRIPTION
40 The
41 .BR pthread_attr_setdetachstate ()
42 function sets the detach state attribute of the
43 thread attributes object referred to by
44 .IR attr
45 to the value specified in
46 .IR detachstate .
47 The detach state attribute determines whether a thread created using
48 the thread attributes object
49 .I attr
50 will be created in a joinable or a detached state.
51
52 The following values may be specified in
53 .IR detachstate :
54 .TP
55 .B PTHREAD_CREATE_DETACHED
56 Threads that are created using
57 .I attr
58 will be created in a detached state.
59 .TP
60 .B PTHREAD_CREATE_JOINABLE
61 Threads that are created using
62 .I attr
63 will be created in a joinable state.
64 .PP
65 The default setting of the detach state attribute in a newly initialized
66 thread attributes object is
67 .BR PTHREAD_CREATE_JOINABLE .
68
69 The
70 .BR pthread_attr_getdetachstate ()
71 returns the detach state attribute of the thread attributes object
72 .IR attr
73 in the buffer pointed to by
74 .IR detachstate .
75 .SH RETURN VALUE
76 On success, these functions return 0;
77 on error, they return a nonzero error number.
78 .SH ERRORS
79 .BR pthread_attr_setdetachstate ()
80 can fail with the following error:
81 .TP
82 .B EINVAL
83 An invalid value was specified in
84 .IR detachstate .
85 .SH CONFORMING TO
86 POSIX.1-2001.
87 .SH NOTES
88 See
89 .BR pthread_create (3)
90 for more details on detached and joinable threads.
91
92 A thread that is created in a joinable state should
93 eventually either be joined using
94 .BR pthread_join (3)
95 or detached using
96 .BR pthread_detach (3);
97 see
98 .BR pthread_create (3).
99
100 It is an error to specify the thread ID of
101 a thread that was created in a detached state
102 in a later call to
103 .BR pthread_detach (3)
104 or
105 .BR pthread_join (3).
106 .SH EXAMPLE
107 See
108 .BR pthread_attr_init (3).
109 .SH SEE ALSO
110 .BR pthread_attr_init (3),
111 .BR pthread_create (3),
112 .BR pthread_detach (3),
113 .BR pthread_join (3),
114 .BR pthreads (7)