1PTHREAD_ATTR_SETDETACHSTATE(L3i)nux Programmer's ManPuTaHlREAD_ATTR_SETDETACHSTATE(3)
2
3
4

NAME

6       pthread_attr_setdetachstate,  pthread_attr_getdetachstate - set/get de‐
7       tach state attribute in thread attributes object
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
13       int pthread_attr_getdetachstate(const pthread_attr_t *attr,
14                                       int *detachstate);
15
16       Compile and link with -pthread.
17

DESCRIPTION

19       The pthread_attr_setdetachstate() function sets the detach state attri‐
20       bute  of  the thread attributes object referred to by attr to the value
21       specified  in  detachstate.   The  detach  state  attribute  determines
22       whether  a  thread created using the thread attributes object attr will
23       be created in a joinable or a detached state.
24
25       The following values may be specified in detachstate:
26
27       PTHREAD_CREATE_DETACHED
28              Threads that are created using attr will be  created  in  a  de‐
29              tached state.
30
31       PTHREAD_CREATE_JOINABLE
32              Threads  that  are created using attr will be created in a join‐
33              able state.
34
35       The default setting of the detach state attribute in a  newly  initial‐
36       ized thread attributes object is PTHREAD_CREATE_JOINABLE.
37
38       The pthread_attr_getdetachstate() returns the detach state attribute of
39       the thread attributes object attr in the buffer pointed to  by  detach‐
40       state.
41

RETURN VALUE

43       On  success,  these functions return 0; on error, they return a nonzero
44       error number.
45

ERRORS

47       pthread_attr_setdetachstate() can fail with the following error:
48
49       EINVAL An invalid value was specified in detachstate.
50

ATTRIBUTES

52       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
53       tributes(7).
54
55       ┌───────────────────────────────┬───────────────┬─────────┐
56Interface                      Attribute     Value   
57       ├───────────────────────────────┼───────────────┼─────────┤
58pthread_attr_setdetachstate(), │ Thread safety │ MT-Safe │
59pthread_attr_getdetachstate()  │               │         │
60       └───────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

62       POSIX.1-2001, POSIX.1-2008.
63

NOTES

65       See  pthread_create(3)  for  more  details  on  detached  and  joinable
66       threads.
67
68       A  thread  that is created in a joinable state should eventually either
69       be joined using pthread_join(3) or  detached  using  pthread_detach(3);
70       see pthread_create(3).
71
72       It is an error to specify the thread ID of a thread that was created in
73       a  detached  state  in   a   later   call   to   pthread_detach(3)   or
74       pthread_join(3).
75

EXAMPLES

77       See pthread_attr_init(3).
78

SEE ALSO

80       pthread_attr_init(3),       pthread_create(3),       pthread_detach(3),
81       pthread_join(3), pthreads(7)
82

COLOPHON

84       This page is part of release 5.10 of the Linux  man-pages  project.   A
85       description  of  the project, information about reporting bugs, and the
86       latest    version    of    this    page,    can     be     found     at
87       https://www.kernel.org/doc/man-pages/.
88
89
90
91Linux                             2020-06-09    PTHREAD_ATTR_SETDETACHSTATE(3)
Impressum