xref: /netbsd-src/lib/libpthread/pthread_attr_getdetachstate.3 (revision 3117ece4fc4a4ca4489ba793710b60b0d26bab6c)
1.\"	$NetBSD: pthread_attr_getdetachstate.3,v 1.4 2017/10/23 01:03:23 wiz Exp $
2.\"
3.\" Copyright (c) 2002, 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
28.\" All rights reserved.
29.\"
30.\" Redistribution and use in source and binary forms, with or without
31.\" modification, are permitted provided that the following conditions
32.\" are met:
33.\" 1. Redistributions of source code must retain the above copyright
34.\"    notice(s), this list of conditions and the following disclaimer as
35.\"    the first lines of this file unmodified other than the possible
36.\"    addition of one or more copyright notices.
37.\" 2. Redistributions in binary form must reproduce the above copyright
38.\"    notice(s), this list of conditions and the following disclaimer in
39.\"    the documentation and/or other materials provided with the
40.\"    distribution.
41.\"
42.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
43.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
46.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
49.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
51.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
52.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.\" $FreeBSD: src/lib/libpthread/man/pthread_attr.3,v 1.11 2002/09/16 19:29:28 mini Exp $
55.\"
56.Dd July 9, 2010
57.Dt PTHREAD_ATTR_GETDETACHSTATE 3
58.Os
59.Sh NAME
60.Nm pthread_attr_getdetachstate ,
61.Nm pthread_attr_setdetachstate
62.Nd get and set the
63.Dq detach state
64attribute
65.Sh LIBRARY
66.Lb libpthread
67.Sh SYNOPSIS
68.In pthread.h
69.Ft int
70.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate"
71.Ft int
72.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
73.Sh DESCRIPTION
74The attribute parameters for the
75.Fn pthread_attr_getdetachstate
76and
77.Fn pthread_attr_setdetachstate
78functions are mutually exclusive and must be one of:
79.Bl -tag -width PTHREAD_CREATE_DETACHED -offset 2n
80.It Dv PTHREAD_CREATE_JOINABLE
81The threads must explicitly be waited for using the
82.Xr pthread_join 3
83function once they exit for their status to be received and their resources
84to be freed.
85This is the default.
86.It Dv PTHREAD_CREATE_DETACHED
87The thread's resources will automatically be freed once the thread exits,
88and the thread will not be joined.
89.El
90.Pp
91If the thread is created as detached,
92it is an error to use the thread ID with
93.Xr pthread_detach 3
94or
95.Xr pthread_join 3 .
96.Sh RETURN VALUES
97If successful, these functions return 0.
98Otherwise, an error number is returned to indicate the error.
99.Sh ERRORS
100No errors are defined for
101.Fn pthread_attr_getdetachstate .
102.Pp
103The
104.Fn pthread_attr_setdetachstate
105function should fail if:
106.Bl -tag -width Er
107.It Bq Er EINVAL
108The value specified by
109.Fa detachstate
110is invalid.
111.El
112.Sh SEE ALSO
113.Xr pthread_attr 3 ,
114.Xr pthread_detach 3 ,
115.Xr pthread_join 3
116.Sh STANDARDS
117Both functions conform to
118.St -p1003.1-2001 .
119