]> git.saurik.com Git - apple/libc.git/blame - pthreads/pthread_attr_set_getdetachstate.3
Libc-583.tar.gz
[apple/libc.git] / pthreads / pthread_attr_set_getdetachstate.3
CommitLineData
34e8f829
A
1.\" Copyright (c) 2004-2007 Apple Inc. All rights reserved.
2.Dd December 31, 2007
3.Dt PTHREAD_ATTR 3
4.Os
5.Sh NAME
6.Nm pthread_attr_getdetachstate ,
7.Nm pthread_attr_setdetachstate
8.Nd thread attribute operations
9.Sh SYNOPSIS
10.Fd #include <pthread.h>
11.Ft int
12.Fo pthread_attr_getdetachstate
13.Fa "const pthread_attr_t *attr"
14.Fa "int *detachstate"
15.Fc
16.Ft int
17.Fo pthread_attr_setdetachstate
18.Fa "pthread_attr_t *attr"
19.Fa "int detachstate"
20.Fc
21.Sh DESCRIPTION
22Thread attributes are used to specify parameters to
23.Fn pthread_create .
24One attribute object can be used in multiple calls to
25.Fn pthread_create ,
26with or without modifications between calls.
27.Pp
28One of these thread attributes governs the creation state of the new thread. The new thread
29can be either created "detached" or "joinable". The constants corresponding to these states are PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE respectively.
30Creating a "joinable" thread allows the user
31to call
32.Fn pthread_join
33and
34.Fn pthread_detach ,
35with the new thread's ID. A "detached" thread's ID cannot be used with
36.Fn pthread_join
37and
38.Fn pthread_detach .
39The default value for the "detachstate" attribute is PTHREAD_CREATE_JOINABLE.
40.Pp
41The
42.Fn pthread_attr_setdetachstate
43function sets the thread's "detachstate" attribute.
44.Pp
45The "detachstate" attribute is set within the
46.Fa attr
47argument, which can subsequently be used as an argument to
48.Fn pthread_create .
49.Sh RETURN VALUES
50If successful, these functions return 0.
51Otherwise, an error number is returned to indicate the error.
52.Fn pthread_attr_getdetachstate ,
53on success, will copy the value of the thread's "detachstate" attribute
54to the location pointed to by the second function parameter.
55.Sh ERRORS
56.Fn pthread_attr_getdetachstate
57will fail if:
58.Bl -tag -width Er
59.\" ========
60.It Bq Er EINVAL
61Invalid value for
62.Fa attr
63.El
64.Pp
65.Fn pthread_attr_setdetachstate
66will fail if:
67.Bl -tag -width Er
68.\" ========
69.It Bq Er EINVAL
70Invalid value for
71.Fa attr
72or
73.Fa detachstate .
74.El
75.Pp
76.Sh SEE ALSO
77.Xr pthread_create 3 ,
78.Xr pthread_join 3 ,
79.Xr pthread_attr_init 3 ,
80.Xr pthread_detach 3
81.Sh STANDARDS
82.Fn pthread_attr_setdetachstate ,
83.Fn pthread_attr_getdetachstate
84conform to
85.St -p1003.1-96
86.Pp