1PTHREAD_ATTR_SETDETACHSTATE(L3i)nux Programmer's ManPuTaHlREAD_ATTR_SETDETACHSTATE(3)
2
3
4
6 pthread_attr_setdetachstate, pthread_attr_getdetachstate - set/get
7 detach state attribute in thread attributes object
8
10 #include <pthread.h>
11
12 int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
13 int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate);
14
15 Compile and link with -pthread.
16
18 The pthread_attr_setdetachstate() function sets the detach state
19 attribute of the thread attributes object referred to by attr to the
20 value specified in detachstate. The detach state attribute determines
21 whether a thread created using the thread attributes object attr will
22 be created in a joinable or a detached state.
23
24 The following values may be specified in detachstate:
25
26 PTHREAD_CREATE_DETACHED
27 Threads that are created using attr will be created in a
28 detached state.
29
30 PTHREAD_CREATE_JOINABLE
31 Threads that are created using attr will be created in a join‐
32 able state.
33
34 The default setting of the detach state attribute in a newly initial‐
35 ized thread attributes object is PTHREAD_CREATE_JOINABLE.
36
37 The pthread_attr_getdetachstate() returns the detach state attribute of
38 the thread attributes object attr in the buffer pointed to by detach‐
39 state.
40
42 On success, these functions return 0; on error, they return a nonzero
43 error number.
44
46 pthread_attr_setdetachstate() can fail with the following error:
47
48 EINVAL An invalid value was specified in detachstate.
49
51 POSIX.1-2001.
52
54 See pthread_create(3) for more details on detached and joinable
55 threads.
56
57 A thread that is created in a joinable state should eventually either
58 be joined using pthread_join(3) or detached using pthread_detach(3);
59 see pthread_create(3).
60
61 It is an error to specify the thread ID of a thread that was created in
62 a detached state in a later call to pthread_detach(3) or
63 pthread_join(3).
64
66 See pthread_attr_init(3).
67
69 pthread_attr_init(3), pthread_create(3), pthread_detach(3),
70 pthread_join(3), pthreads(7)
71
73 This page is part of release 3.53 of the Linux man-pages project. A
74 description of the project, and information about reporting bugs, can
75 be found at http://www.kernel.org/doc/man-pages/.
76
77
78
79Linux 2010-02-03 PTHREAD_ATTR_SETDETACHSTATE(3)