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