summaryrefslogtreecommitdiff
path: root/lib/libpthread/man/pthread_attr_setdetachstate.3
blob: fa27a96e7c5c25a821458d917e15cd53b2f40516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.\" $OpenBSD: pthread_attr_setdetachstate.3,v 1.9 2008/12/18 09:30:32 guenther Exp $
.\" Manual page derived from TOG's UNIX98 documentation.
.\"
.\"  David Leonard, 2000. Public Domain.
.\"
.Dd $Mdocdate: December 18 2008 $
.Dt PTHREAD_ATTR_SETDETACHSTATE 3
.Os
.Sh NAME
.Nm pthread_attr_setdetachstate ,
.Nm pthread_attr_getdetachstate
.Nd set and get detachstate attribute
.Sh SYNOPSIS
.Fd #include <pthread.h>
.Ft int
.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
.Ft int
.Fn pthread_attr_getdetachstate "pthread_attr_t *attr" "int *detachstate"
.Sh DESCRIPTION
The
.Va detachstate
attribute controls whether the thread is created in
a detached state.
If the thread is created detached, then use of
the ID of the newly created thread by the
.Xr pthread_detach 3
or
.Xr pthread_join 3
function is an error.
.Pp
The
.Fn pthread_attr_setdetachstate
and
.Fn pthread_attr_getdetachstate
functions, respectively, set and get the
.Va detachstate
attribute in the
.Fa attr
object.
.Pp
The
.Fa detachstate
can be set to either
.Dv PTHREAD_CREATE_DETACHED
or
.Dv PTHREAD_CREATE_JOINABLE .
A value of
.Dv PTHREAD_CREATE_DETACHED
causes
all threads created with
.Fa attr
to be in the detached state, whereas
using a value of
.Dv PTHREAD_CREATE_JOINABLE
causes all threads created
with
.Fa attr
to be in the joinable state.
The default value of the
.Va detachstate
attribute is
.Dv PTHREAD_CREATE_JOINABLE .
.Sh RETURN VALUES
Upon successful completion,
.Fn pthread_attr_setdetachstate
and
.Fn pthread_attr_getdetachstate
return a value of 0.
Otherwise, an error number is returned to indicate the error.
.Pp
The
.Fn pthread_attr_getdetachstate
function stores the value of the
.Va detachstate
attribute in
.Fa detachstate
if successful.
.Sh ERRORS
The
.Fn pthread_attr_setdetachstate
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The value of
.Fa detachstate
was not valid.
.El
.Pp
These functions will not return an error code of
.Bq Er EINTR .
.Sh SEE ALSO
.Xr pthread_attr_init 3 ,
.Xr pthread_attr_setguardsize 3 ,
.Xr pthread_attr_setstack 3 ,
.Xr pthread_attr_setstackaddr 3 ,
.Xr pthread_attr_setstacksize 3 ,
.Xr pthread_create 3 ,
.Xr pthreads 3
.Sh STANDARDS
.Fn pthread_attr_setdetachstate
and
.Fn pthread_attr_getdetachstate
conform to ISO/IEC 9945-1 ANSI/IEEE
.Pq Dq Tn POSIX
Std 1003.1 Second Edition 1996-07-12.