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

NAME

6       pthread_attr_setdetachstate,   pthread_attr_getdetachstate   -  set/get
7       detach 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, int *detachstate);
14
15       Compile and link with -pthread.
16

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

EXAMPLE

76       See pthread_attr_init(3).
77

SEE ALSO

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

COLOPHON

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