1PTHREAD_ATTR_GETDETACHSTATE(P3OPS)IX Programmer's MaPnTuHaRlEAD_ATTR_GETDETACHSTATE(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       pthread_attr_getdetachstate, pthread_attr_setdetachstate — get and set
14       the detachstate attribute
15

SYNOPSIS

17       #include <pthread.h>
18
19       int pthread_attr_getdetachstate(const pthread_attr_t *attr,
20           int *detachstate);
21       int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
22

DESCRIPTION

24       The  detachstate  attribute controls whether the thread is created in a
25       detached state.  If the thread is created detached, then use of the  ID
26       of  the  newly created thread by the pthread_detach() or pthread_join()
27       function is an error.
28
29       The  pthread_attr_getdetachstate()  and   pthread_attr_setdetachstate()
30       functions, respectively, shall get and set the detachstate attribute in
31       the attr object.
32
33       For pthread_attr_getdetachstate(), detachstate shall be set  to  either
34       PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.
35
36       For  pthread_attr_setdetachstate(),  the  application shall set detach‐
37       state to either PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.
38
39       A value of PTHREAD_CREATE_DETACHED shall cause all threads created with
40       attr to be in the detached state, whereas using a value of PTHREAD_CRE‐
41       ATE_JOINABLE shall cause all threads created with attr  to  be  in  the
42       joinable state. The default value of the detachstate attribute shall be
43       PTHREAD_CREATE_JOINABLE.
44
45       The behavior is undefined if the value specified by the  attr  argument
46       to  pthread_attr_getdetachstate() or pthread_attr_setdetachstate() does
47       not refer to an initialized thread attributes object.
48

RETURN VALUE

50       Upon   successful   completion,    pthread_attr_getdetachstate()    and
51       pthread_attr_setdetachstate()  shall return a value of 0; otherwise, an
52       error number shall be returned to indicate the error.
53
54       The pthread_attr_getdetachstate() function  stores  the  value  of  the
55       detachstate attribute in detachstate if successful.
56

ERRORS

58       The pthread_attr_setdetachstate() function shall fail if:
59
60       EINVAL The value of detachstate was not valid
61
62       These functions shall not return an error code of [EINTR].
63
64       The following sections are informative.
65

EXAMPLES

67   Retrieving the detachstate Attribute
68       This  example shows how to obtain the detachstate attribute of a thread
69       attribute object.
70
71           #include <pthread.h>
72
73           pthread_attr_t thread_attr;
74           int            detachstate;
75           int            rc;
76
77           /* code initializing thread_attr */
78           ...
79
80           rc = pthread_attr_getdetachstate (&thread_attr, &detachstate);
81           if (rc!=0) {
82               /* handle error */
83               ...
84           }
85           else {
86               /* legal values for detachstate are:
87                * PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE
88                */
89                ...
90           }
91

APPLICATION USAGE

93       None.
94

RATIONALE

96       If an implementation detects that the value specified by the attr argu‐
97       ment  to pthread_attr_getdetachstate() or pthread_attr_setdetachstate()
98       does not refer to an initialized thread attributes object, it is recom‐
99       mended that the function should fail and report an [EINVAL] error.
100

FUTURE DIRECTIONS

102       None.
103

SEE ALSO

105       pthread_attr_destroy(), pthread_attr_getstacksize(), pthread_create()
106
107       The Base Definitions volume of POSIX.1‐2008, <pthread.h>
108
110       Portions  of  this text are reprinted and reproduced in electronic form
111       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
112       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
113       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
114       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
115       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
116       event of any discrepancy between this version and the original IEEE and
117       The Open Group Standard, the original IEEE and The Open Group  Standard
118       is  the  referee document. The original Standard can be obtained online
119       at http://www.unix.org/online.html .
120
121       Any typographical or formatting errors that appear  in  this  page  are
122       most likely to have been introduced during the conversion of the source
123       files to man page format. To report such errors,  see  https://www.ker
124       nel.org/doc/man-pages/reporting_bugs.html .
125
126
127
128IEEE/The Open Group                  2013      PTHREAD_ATTR_GETDETACHSTATE(3P)
Impressum