1pthread_attr_getdetachstatSet(a3nCd)ard C Library Funcpttihornesad_attr_getdetachstate(3C)
2
3
4
6 pthread_attr_getdetachstate, pthread_attr_setdetachstate - get or set
7 detachstate attribute
8
10 cc -mt [ flag... ] file... -lpthread [ library... ]
11 #include <pthread.h>
12
13 int pthread_attr_setdetachstate(pthread_attr_t *attr,
14 int detachstate);
15
16
17 int pthread_attr_getdetachstate(const pthread_attr_t *attr,
18 int *detachstate);
19
20
22 The detachstate attribute controls whether the thread is created in a
23 detached state. If the thread is created detached, then use of the ID
24 of the newly created thread by the pthread_detach() or pthread_join()
25 function is an error.
26
27
28 The pthread_attr_setdetachstate() and pthread_attr_getdetachstate(),
29 respectively, set and get the detachstate attribute in the attr object.
30
31
32 The detachstate can be set to either PTHREAD_CREATE_DETACHED or
33 PTHREAD_CREATE_JOINABLE. A value of PTHREAD_CREATE_DETACHED causes all
34 threads created with attr to be in the detached state, whereas using a
35 value of PTHREAD_CREATE_JOINABLE causes all threads created with attr
36 to be in the joinable state. The default value of the detachstate
37 attribute is PTHREAD_CREATE_JOINABLE.
38
40 Upon successful completion, pthread_attr_setdetachstate() and
41 pthread_attr_getdetachstate() return a value of 0. Otherwise, an error
42 number is returned to indicate the error.
43
44
45 The pthread_attr_getdetachstate() function stores the value of the
46 detachstate attribute in detachstate if successful.
47
49 The pthread_attr_setdetachstate() or pthread_attr_getdetachstate()
50 functions may fail if:
51
52 EINVAL attr or detachstate is invalid.
53
54
56 See attributes(5) for descriptions of the following attributes:
57
58
59
60
61 ┌─────────────────────────────┬─────────────────────────────┐
62 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
63 ├─────────────────────────────┼─────────────────────────────┤
64 │Interface Stability │Standard │
65 ├─────────────────────────────┼─────────────────────────────┤
66 │MT-Level │MT-Safe │
67 └─────────────────────────────┴─────────────────────────────┘
68
70 pthread_attr_init(3C), pthread_attr_setstackaddr(3C), pthread_attr_set‐
71 stacksize(3C), pthread_create(3C), attributes(5), standards(5)
72
73
74
75SunOS 5.11 23 Mar 2005 pthread_attr_getdetachstate(3C)