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_detach.3p (3743B)


  1. '\" et
  2. .TH PTHREAD_DETACH "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. pthread_detach
  12. \(em detach a thread
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <pthread.h>
  17. .P
  18. int pthread_detach(pthread_t \fIthread\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIpthread_detach\fR()
  23. function shall indicate to the implementation that storage for the
  24. thread
  25. .IR thread
  26. can be reclaimed when that thread terminates. If
  27. .IR thread
  28. has not terminated,
  29. \fIpthread_detach\fR()
  30. shall not cause it to terminate.
  31. .P
  32. The behavior is undefined if the value specified by the
  33. .IR thread
  34. argument to
  35. \fIpthread_detach\fR()
  36. does not refer to a joinable thread.
  37. .SH "RETURN VALUE"
  38. If the call succeeds,
  39. \fIpthread_detach\fR()
  40. shall return 0; otherwise, an error number shall be returned to
  41. indicate the error.
  42. .SH ERRORS
  43. The
  44. \fIpthread_detach\fR()
  45. function shall not return an error code of
  46. .BR [EINTR] .
  47. .LP
  48. .IR "The following sections are informative."
  49. .SH EXAMPLES
  50. None.
  51. .SH "APPLICATION USAGE"
  52. None.
  53. .SH RATIONALE
  54. The
  55. \fIpthread_join\fR()
  56. or
  57. \fIpthread_detach\fR()
  58. functions should eventually be called for every thread that is created
  59. so that storage associated with the thread may be reclaimed.
  60. .P
  61. It has been suggested that a ``detach'' function is not necessary; the
  62. .IR detachstate
  63. thread creation attribute is sufficient, since a thread need never be
  64. dynamically detached. However, need arises in at least two cases:
  65. .IP " 1." 4
  66. In a cancellation handler for a
  67. \fIpthread_join\fR()
  68. it is nearly essential to have a
  69. \fIpthread_detach\fR()
  70. function in order to detach the thread on which
  71. \fIpthread_join\fR()
  72. was waiting. Without it, it would be necessary to have the handler do
  73. another
  74. \fIpthread_join\fR()
  75. to attempt to detach the thread, which would both delay the cancellation
  76. processing for an unbounded period and introduce a new call to
  77. \fIpthread_join\fR(),
  78. which might itself need a cancellation handler. A dynamic detach is
  79. nearly essential in this case.
  80. .IP " 2." 4
  81. In order to detach the ``initial thread'' (as may be desirable in
  82. processes that set up server threads).
  83. .P
  84. If an implementation detects that the value specified by the
  85. .IR thread
  86. argument to
  87. \fIpthread_detach\fR()
  88. does not refer to a joinable thread, it is recommended that the
  89. function should fail and report an
  90. .BR [EINVAL]
  91. error.
  92. .P
  93. If an implementation detects use of a thread ID after the end of its
  94. lifetime, it is recommended that the function should fail and report an
  95. .BR [ESRCH]
  96. error.
  97. .SH "FUTURE DIRECTIONS"
  98. None.
  99. .SH "SEE ALSO"
  100. .IR "\fIpthread_join\fR\^(\|)"
  101. .P
  102. The Base Definitions volume of POSIX.1\(hy2017,
  103. .IR "\fB<pthread.h>\fP"
  104. .\"
  105. .SH COPYRIGHT
  106. Portions of this text are reprinted and reproduced in electronic form
  107. from IEEE Std 1003.1-2017, Standard for Information Technology
  108. -- Portable Operating System Interface (POSIX), The Open Group Base
  109. Specifications Issue 7, 2018 Edition,
  110. Copyright (C) 2018 by the Institute of
  111. Electrical and Electronics Engineers, Inc and The Open Group.
  112. In the event of any discrepancy between this version and the original IEEE and
  113. The Open Group Standard, the original IEEE and The Open Group Standard
  114. is the referee document. The original Standard can be obtained online at
  115. http://www.opengroup.org/unix/online.html .
  116. .PP
  117. Any typographical or formatting errors that appear
  118. in this page are most likely
  119. to have been introduced during the conversion of the source files to
  120. man page format. To report such errors, see
  121. https://www.kernel.org/doc/man-pages/reporting_bugs.html .