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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

66   Retrieving the detachstate Attribute
67       This  example shows how to obtain the detachstate attribute of a thread
68       attribute object.
69
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‐2017, <pthread.h>
108
110       Portions  of  this text are reprinted and reproduced in electronic form
111       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
112       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
113       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
114       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
115       event of any discrepancy between this version and the original IEEE and
116       The  Open Group Standard, the original IEEE and The Open Group Standard
117       is the referee document. The original Standard can be  obtained  online
118       at http://www.opengroup.org/unix/online.html .
119
120       Any  typographical  or  formatting  errors that appear in this page are
121       most likely to have been introduced during the conversion of the source
122       files  to  man page format. To report such errors, see https://www.ker
123       nel.org/doc/man-pages/reporting_bugs.html .
124
125
126
127IEEE/The Open Group                  2017      PTHREAD_ATTR_GETDETACHSTATE(3P)
Impressum