1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
1 |
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved |
2
by Francesco Paolo Lovergine
* Alligned to linux main manpages edition. |
2 |
.TH "PTHREAD_DETACH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" |
1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
3 |
.\" pthread_detach |
4 |
.SH NAME |
|
5 |
pthread_detach \- detach a thread
|
|
6 |
.SH SYNOPSIS |
|
7 |
.LP
|
|
8 |
\fB#include <pthread.h>
|
|
9 |
.br
|
|
10 |
.sp
|
|
11 |
int pthread_detach(pthread_t\fP \fIthread\fP\fB); \fP |
|
12 |
\fB
|
|
13 |
.br
|
|
14 |
\fP
|
|
15 |
.SH DESCRIPTION |
|
16 |
.LP
|
|
17 |
The \fIpthread_detach\fP() function shall indicate to the implementation |
|
18 |
that storage for the thread \fIthread\fP can be |
|
19 |
reclaimed when that thread terminates. If \fIthread\fP has not terminated, |
|
20 |
\fIpthread_detach\fP() shall not cause it to |
|
21 |
terminate. The effect of multiple \fIpthread_detach\fP() calls on |
|
22 |
the same target thread is unspecified. |
|
23 |
.SH RETURN VALUE |
|
24 |
.LP
|
|
25 |
If the call succeeds, \fIpthread_detach\fP() shall return 0; otherwise, |
|
26 |
an error number shall be returned to indicate the |
|
27 |
error. |
|
28 |
.SH ERRORS |
|
29 |
.LP
|
|
30 |
The \fIpthread_detach\fP() function shall fail if: |
|
31 |
.TP 7 |
|
32 |
.B EINVAL |
|
33 |
The implementation has detected that the value specified by \fIthread\fP |
|
34 |
does not refer to a joinable thread. |
|
35 |
.TP 7 |
|
36 |
.B ESRCH |
|
37 |
No thread could be found corresponding to that specified by the given |
|
38 |
thread ID. |
|
39 |
.sp
|
|
40 |
.LP
|
|
41 |
The \fIpthread_detach\fP() function shall not return an error code |
|
42 |
of [EINTR]. |
|
43 |
.LP
|
|
44 |
\fIThe following sections are informative.\fP |
|
45 |
.SH EXAMPLES |
|
46 |
.LP
|
|
47 |
None. |
|
48 |
.SH APPLICATION USAGE |
|
49 |
.LP
|
|
50 |
None. |
|
51 |
.SH RATIONALE |
|
52 |
.LP
|
|
53 |
The \fIpthread_join\fP() or \fIpthread_detach\fP() functions should |
|
54 |
eventually be |
|
55 |
called for every thread that is created so that storage associated |
|
56 |
with the thread may be reclaimed. |
|
57 |
.LP
|
|
58 |
It has been suggested that a "detach" function is not necessary; the |
|
59 |
\fIdetachstate\fP thread creation attribute is |
|
60 |
sufficient, since a thread need never be dynamically detached. However, |
|
61 |
need arises in at least two cases: |
|
62 |
.IP " 1." 4 |
|
63 |
In a cancellation handler for a \fIpthread_join\fP() it is nearly |
|
64 |
essential to |
|
65 |
have a \fIpthread_detach\fP() function in order to detach the thread |
|
66 |
on which \fIpthread_join\fP() was waiting. Without it, it would be |
|
67 |
necessary to have the handler do |
|
68 |
another \fIpthread_join\fP() to attempt to detach the thread, which |
|
69 |
would both delay |
|
70 |
the cancellation processing for an unbounded period and introduce |
|
71 |
a new call to \fIpthread_join\fP(), which might itself need a cancellation |
|
72 |
handler. A dynamic detach is |
|
73 |
nearly essential in this case. |
|
74 |
.LP
|
|
75 |
.IP " 2." 4 |
|
76 |
In order to detach the "initial thread" (as may be desirable in processes |
|
77 |
that set up server threads). |
|
78 |
.LP
|
|
79 |
.SH FUTURE DIRECTIONS |
|
80 |
.LP
|
|
81 |
None. |
|
82 |
.SH SEE ALSO |
|
83 |
.LP
|
|
84 |
\fIpthread_join\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, |
|
85 |
\fI<pthread.h>\fP |
|
86 |
.SH COPYRIGHT |
|
87 |
Portions of this text are reprinted and reproduced in electronic form |
|
88 |
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology |
|
89 |
-- Portable Operating System Interface (POSIX), The Open Group Base |
|
90 |
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of |
|
91 |
Electrical and Electronics Engineers, Inc and The Open Group. In the |
|
92 |
event of any discrepancy between this version and the original IEEE and |
|
93 |
The Open Group Standard, the original IEEE and The Open Group Standard |
|
94 |
is the referee document. The original Standard can be obtained online at |
|
95 |
http://www.opengroup.org/unix/online.html . |