logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

pthread_attr_getdetachstate.3p (4595B)


  1. '\" et
  2. .TH PTHREAD_ATTR_GETDETACHSTATE "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. .ad l
  12. pthread_attr_getdetachstate,
  13. pthread_attr_setdetachstate
  14. \(em get and set the detachstate attribute
  15. .ad b
  16. .SH SYNOPSIS
  17. .LP
  18. .nf
  19. #include <pthread.h>
  20. .P
  21. int pthread_attr_getdetachstate(const pthread_attr_t *\fIattr\fP,
  22. int *\fIdetachstate\fP);
  23. int pthread_attr_setdetachstate(pthread_attr_t *\fIattr\fP, int \fIdetachstate\fP);
  24. .fi
  25. .SH DESCRIPTION
  26. The
  27. .IR detachstate
  28. attribute controls whether the thread is created in a detached state.
  29. If the thread is created detached, then use of the ID of the newly
  30. created thread by the
  31. \fIpthread_detach\fR()
  32. or
  33. \fIpthread_join\fR()
  34. function is an error.
  35. .P
  36. The
  37. \fIpthread_attr_getdetachstate\fR()
  38. and
  39. \fIpthread_attr_setdetachstate\fR()
  40. functions, respectively, shall get and set the
  41. .IR detachstate
  42. attribute in the
  43. .IR attr
  44. object.
  45. .P
  46. For
  47. \fIpthread_attr_getdetachstate\fR(),
  48. .IR detachstate
  49. shall be set to either PTHREAD_CREATE_DETACHED or
  50. PTHREAD_CREATE_JOINABLE.
  51. .P
  52. For
  53. \fIpthread_attr_setdetachstate\fR(),
  54. the application shall set
  55. .IR detachstate
  56. to either PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE.
  57. .P
  58. A value of PTHREAD_CREATE_DETACHED shall cause all threads created with
  59. .IR attr
  60. to be in the detached state, whereas using a value of
  61. PTHREAD_CREATE_JOINABLE shall cause all threads created with
  62. .IR attr
  63. to be in the joinable state. The default value of the
  64. .IR detachstate
  65. attribute shall be PTHREAD_CREATE_JOINABLE.
  66. .P
  67. The behavior is undefined if the value specified by the
  68. .IR attr
  69. argument to
  70. \fIpthread_attr_getdetachstate\fR()
  71. or
  72. \fIpthread_attr_setdetachstate\fR()
  73. does not refer to an initialized thread attributes object.
  74. .SH "RETURN VALUE"
  75. Upon successful completion,
  76. \fIpthread_attr_getdetachstate\fR()
  77. and
  78. \fIpthread_attr_setdetachstate\fR()
  79. shall return a value of 0; otherwise, an error number shall be
  80. returned to indicate the error.
  81. .P
  82. The
  83. \fIpthread_attr_getdetachstate\fR()
  84. function stores the value of the
  85. .IR detachstate
  86. attribute in
  87. .IR detachstate
  88. if successful.
  89. .SH ERRORS
  90. The
  91. \fIpthread_attr_setdetachstate\fR()
  92. function shall fail if:
  93. .TP
  94. .BR EINVAL
  95. The value of
  96. .IR detachstate
  97. was not valid
  98. .P
  99. These functions shall not return an error code of
  100. .BR [EINTR] .
  101. .LP
  102. .IR "The following sections are informative."
  103. .SH EXAMPLES
  104. .SS "Retrieving the detachstate Attribute"
  105. .P
  106. This example shows how to obtain the
  107. .IR detachstate
  108. attribute of a thread attribute object.
  109. .sp
  110. .RS 4
  111. .nf
  112. #include <pthread.h>
  113. .P
  114. pthread_attr_t thread_attr;
  115. int detachstate;
  116. int rc;
  117. .P
  118. /* code initializing thread_attr */
  119. \&...
  120. .P
  121. rc = pthread_attr_getdetachstate (&thread_attr, &detachstate);
  122. if (rc!=0) {
  123. /* handle error */
  124. ...
  125. }
  126. else {
  127. /* legal values for detachstate are:
  128. * PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE
  129. */
  130. ...
  131. }
  132. .fi
  133. .P
  134. .RE
  135. .SH "APPLICATION USAGE"
  136. None.
  137. .SH RATIONALE
  138. If an implementation detects that the value specified by the
  139. .IR attr
  140. argument to
  141. \fIpthread_attr_getdetachstate\fR()
  142. or
  143. \fIpthread_attr_setdetachstate\fR()
  144. does not refer to an initialized thread attributes object, it is
  145. recommended that the function should fail and report an
  146. .BR [EINVAL]
  147. error.
  148. .SH "FUTURE DIRECTIONS"
  149. None.
  150. .SH "SEE ALSO"
  151. .IR "\fIpthread_attr_destroy\fR\^(\|)",
  152. .IR "\fIpthread_attr_getstacksize\fR\^(\|)",
  153. .IR "\fIpthread_create\fR\^(\|)"
  154. .P
  155. The Base Definitions volume of POSIX.1\(hy2017,
  156. .IR "\fB<pthread.h>\fP"
  157. .\"
  158. .SH COPYRIGHT
  159. Portions of this text are reprinted and reproduced in electronic form
  160. from IEEE Std 1003.1-2017, Standard for Information Technology
  161. -- Portable Operating System Interface (POSIX), The Open Group Base
  162. Specifications Issue 7, 2018 Edition,
  163. Copyright (C) 2018 by the Institute of
  164. Electrical and Electronics Engineers, Inc and The Open Group.
  165. In the event of any discrepancy between this version and the original IEEE and
  166. The Open Group Standard, the original IEEE and The Open Group Standard
  167. is the referee document. The original Standard can be obtained online at
  168. http://www.opengroup.org/unix/online.html .
  169. .PP
  170. Any typographical or formatting errors that appear
  171. in this page are most likely
  172. to have been introduced during the conversion of the source files to
  173. man page format. To report such errors, see
  174. https://www.kernel.org/doc/man-pages/reporting_bugs.html .