File: pthread_detach.3

package info (click to toggle)
manpages-ja 0.5.0.0.20180315%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 28,516 kB
  • sloc: perl: 161; makefile: 101
file content (112 lines) | stat: -rw-r--r-- 3,356 bytes parent folder | download | duplicates (6)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.\"   Copyright (C) 1996-1999 Free Software Foundation, Inc.
.\"
.\"   Permission is granted to make and distribute verbatim copies of
.\" this manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\"   Permission is granted to copy and distribute modified versions of
.\" this manual under the conditions for verbatim copying, provided that
.\" the entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\"   Permission is granted to copy and distribute translations of this
.\" manual into another language, under the above conditions for modified
.\" versions, except that this permission notice may be stated in a
.\" translation approved by the Foundation.
.\"
.\" Copyright (C) 1996 Xavier Leroy.
.\" 
.\" Japanese Version Copyright (C) 1999 GOTO, Masanori
.\"         all rights reserved.
.\" Translated on Tue Dec 14 21:30:57 JST 1999
.\"         by GOTO, Masanori <gotom@debian.or.jp>.
.\" Modified Sun Feb  2 01:00:26 JST 2003
.\"         by Suzuki Takashi.
.\"
.\"WORD:    thread              スレッド
.\"WORD:    detach              デタッチ
.\"WORD:    detached state      デタッチ状態
.\"WORD:    memory resources    メモリ資源
.\"WORD:    free                解放
.\"WORD:    synchronize         同期する
.\"WORD:    termination         終了
.\"WORD:    create              生成
.\"WORD:    attribute           属性
.\"WORD:    joinable            合流可能
.\"WORD:    join                合流
.\"WORD:    error code          エラーコード
.\"
.\"
.TH PTHREAD_DETACH 3 LinuxThreads

.SH "名前"
pthread_detach \- 実行中のスレッドをデタッチ状態にする

.SH "書式"
.B #include <pthread.h>

.BI "int pthread_detach(pthread_t " th ");"

.SH "説明"
.B "pthread_detach"
はスレッド
.I "th"
をデタッチ状態にする。これは
.I "th"
が終了したときに、
.I "th"
によって消費されていたメモリ資源を即座に解放することを保証する。
しかしながら、これによって他のスレッドは
.B "pthread_join"
を用いて
.I "th"
の終了に同期することができなくなる。

スレッドは
.BR "pthread_create" (3)
の属性に
.B "detachstate"
を用いることによって、最初からデタッチ状態で生成
することができる。
これに対し、
.B "pthread_detach"
は合流可能状態として生成され、後にデタッチ状態にする必要の出てきた
スレッドに適用される。

.B "pthread_detach"
が完了した後、
.I "th"
に対して
.B "pthread_join"
を実行しても失敗する。もし
.B "pthread_detach"
が呼ばれた時に別のスレッドがスレッド
.I "th"
の終了を待っている (joining) ならば、
.B "pthread_detach"
は何もせず、
.I "th"
を合流可能状態のままにしておく。

.SH "返り値"
成功すると 0 が返る。エラーの場合は、非 0 のエラーコードが返る。

.SH "エラー"
.TP
.B "ESRCH"
.I "th"
で指定したスレッドが見つからない。
.TP
.B "EINVAL"
スレッド
.I "th"
は既にデタッチ状態にある。
.TP

.SH "著者"
Xavier Leroy <Xavier.Leroy@inria.fr>

.SH "関連項目"
.BR "pthread_create" (3),
.BR "pthread_join" (3),
.BR "pthread_attr_setdetachstate" (3)