xref: /netbsd-src/lib/libpthread/pthread_attr_getdetachstate.3 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\"	$NetBSD: pthread_attr_getdetachstate.3,v 1.2 2010/07/09 08:51:28 jruoho 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.Nd get and set the
62.Dq detach state
63attribute
64.Sh LIBRARY
65.Lb libpthread
66.Sh SYNOPSIS
67.In pthread.h
68.Ft int
69.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate"
70.Ft int
71.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate"
72.Sh DESCRIPTION
73The attribute parameters for the
74.Fn pthread_attr_getdetachstate
75and
76.Fn pthread_attr_setdetachstate
77functions are mutually exclusive and must be one of:
78.Bl -tag -width PTHREAD_CREATE_DETACHED -offset 2n
79.It Dv PTHREAD_CREATE_JOINABLE
80The threads must explicitly be waited for using the
81.Xr pthread_join 3
82function once they exit for their status to be received and their resources
83to be freed.
84This is the default.
85.It Dv PTHREAD_CREATE_DETACHED
86The thread's resources will automatically be freed once the thread exits,
87and the thread will not be joined.
88.El
89.Pp
90If the thread is created as detached,
91it is an error to use the thread
92.Tn ID
93with
94.Xr pthread_detach 3
95or
96.Xr pthread_join 3 .
97.Sh RETURN VALUES
98If successful, these functions return 0.
99Otherwise, an error number is returned to indicate the error.
100.Sh ERRORS
101No errors are defined for
102.Fn pthread_attr_getdetachstate .
103.Pp
104The
105.Fn pthread_attr_setdetachstate
106function should fail if:
107.Bl -tag -width Er
108.It Bq Er EINVAL
109The value specified by
110.Fa detachstate
111is invalid.
112.El
113.Sh SEE ALSO
114.Xr pthread_attr 3 ,
115.Xr pthread_detach 3 ,
116.Xr pthread_join 3
117.Sh STANDARDS
118Both functions conform to
119.St -p1003.1-2001 .
120