summaryrefslogtreecommitdiff
path: root/manual/pthread_detach.html
blob: a6984c90f353a259b7a986c1268c9e1dd1354482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE>PTHREAD_DETACH(3) manual page</TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3  (Linux)">
	<META NAME="CREATED" CONTENT="20050504;18010700">
	<META NAME="CHANGED" CONTENT="20050504;18032100">
	<!-- manual page source format generated by PolyglotMan v3.2, -->
	<!-- available at http://polyglotman.sourceforge.net/ -->
</HEAD>
<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http:sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
<P><A HREF="index.html">Reference Index</A></P>
<P><A HREF="#toc">Table of Contents</A></P>
<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
<P>pthread_detach - put a running thread in the detached state 
</P>
<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
<P><B>#include &lt;pthread.h&gt;</B> 
</P>
<P><B>int pthread_detach(pthread_t </B><I>th</I><B>);</B> 
</P>
<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
<P><B>pthread_detach</B> puts the thread <I>th</I> in the detached
state. This guarantees that the memory resources consumed by <I>th</I>
will be freed immediately when <I>th</I> terminates. However, this
prevents other threads from synchronizing on the termination of <I>th</I>
using <B>pthread_join</B>. 
</P>
<P>A thread can be created initially in the detached state, using the
<B>detachstate</B> attribute to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A>
. In contrast, <B>pthread_detach</B> applies to threads created in
the joinable state, and which need to be put in the detached state
later. 
</P>
<P>After <B>pthread_detach</B> completes, subsequent attempts to
perform <B>pthread_join</B> on <I>th</I> will fail. If another thread
is already joining the thread <I>th</I> at the time <B>pthread_detach</B>
is called, <B>pthread_detach</B> does nothing and leaves <I>th</I> in
the joinable state. 
</P>
<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
<P>On success, 0 is returned. On error, a non-zero error code is
returned. 
</P>
<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
<DL>
	<DT><B>ESRCH</B> 
	</DT><DD>
	No thread could be found corresponding to that specified by <I>th</I>
		</DD><DT>
	<B>EINVAL</B> 
	</DT><DD STYLE="margin-bottom: 0.5cm">
	the thread <I>th</I> is already in the detached state 
	</DD></DL>
<H2>
<A HREF="#toc5" NAME="sect5">Author</A></H2>
<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt; 
</P>
<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2>
<P><A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> ,
<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> ,
<A HREF="pthread_attr_setdetachstate.html"><B>pthread_attr_setdetachstate</B>(3)</A>
</P>
<HR>
<P><A NAME="toc"></A><B>Table of Contents</B></P>
<UL>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
		</P>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
		</P>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
		</P>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
	Value</A> 
	</P>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
		</P>
	<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A>
		</P>
	<LI><P><A HREF="#sect6" NAME="toc6">See Also</A> 
	</P>
</UL>
</BODY>
</HTML>