OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man3 / pthread_join.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" Japanese Version Copyright (c) 2012  Akihiro MOTOKI
33 .\"         all rights reserved.
34 .\" Translated 2012-05-04, Akihiro MOTOKI <amotoki@gmail.com>
35 .\"
36 .TH PTHREAD_JOIN 3 2008\-11\-27 Linux "Linux Programmer's Manual"
37 .SH 名前
38 pthread_join \- 終了したスレッドを join する
39 .SH 書式
40 .nf
41 \fB#include <pthread.h>\fP
42
43 \fBint pthread_join(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB);\fP
44 .fi
45 .sp
46 \fI\-pthread\fP を付けてコンパイルとリンクを行う。
47 .SH 説明
48 \fBpthread_join\fP() 関数は、\fIthread\fP で指定されたスレッドが
49 終了するのを待つ。そのスレッドがすでに終了している場合、
50 \fBpthread_join\fP() はすぐに返る。
51 \fIthread\fP で指定されたスレッドは join 可能でなければならない。
52
53 \fIretval\fP が NULL でない場合、 \fBpthread_join\fP() は対象スレッドの終了
54 ステータス (すなわち、対象スレッドが \fBpthread_exit\fP(3) に渡した値) を
55 \fI*retval\fP が指す場所にコピーする。対象スレッドがキャンセルされた場合、
56 \fI*retval\fP には \fBPTHREAD_CANCELED\fP が格納される。
57
58 複数のスレッドが同時に同じスレッドを join しようとした場合、その結果
59 は不定である。\fBpthread_join\fP() を呼び出しているスレッドがキャンセル
60 された場合、対象スレッドは join 可能のままとなる (detached 状態には
61 ならない)。
62 .SH 返り値
63 成功すると、 \fBpthread_join\fP() は 0 を返す。
64 エラーの場合、エラー番号を返す。
65 .SH エラー
66 .TP 
67 \fBEDEADLK\fP
68 .\" The following verified by testing on glibc 2.8/NPTL:
69 .\" The following verified by testing on glibc 2.8/NPTL:
70 デッドロックが検出された (例えば、二つのスレッドが互いに join しようと
71 した場合)、または \fIthread\fP に呼び出したスレッドが指定されている。
72 .TP 
73 \fBEINVAL\fP
74 \fIthread\fP が join 可能なスレッドではない。
75 .TP 
76 \fBEINVAL\fP
77 .\" POSIX.1-2001 does not specify this error case.
78 別のスレッドがすでにこのスレッドの join 待ちである。
79 .TP 
80 \fBESRCH\fP
81 ID が \fIthread\fP のスレッドが見つからなかった。
82 .SH 準拠
83 POSIX.1\-2001.
84 .SH 注意
85 \fBpthread_join\fP() の呼び出しが成功した場合は、
86 呼び出し側には、対象スレッドが終了していることが保証される。
87
88 すでに join されたスレッドを join した場合の結果は不定である。
89
90 join 可能なスレッド (detached 状態でないスレッド) の join に失敗した場合、
91 "ゾンビスレッド (zombie thread)" が生成される。
92 各ゾンビスレッドはシステムリソースをいくらかは消費し、
93 ゾンビスレッドがたくさん生成されてしまうと、
94 新しいスレッド (やプロセス) がそれ以上作成できなくなってしまうので、
95 このようなことが起きるのは避けること。
96
97 pthreads には、 \fIwaitpid(\-1,\ &status,\ 0)\fP、つまり
98 "終了されたスレッドのどれかを join する" といった機能はない。
99 この機能が必要だと思うような場合には、おそらく
100 自分のアプリケーションの設計を考え直す必要があるだろう。
101
102 プロセス内の全てのスレッドは対等であり、
103 どのスレッドでもプロセス内の他のスレッドを join できる。
104 .SH 例
105 \fBpthread_create\fP(3) を参照。
106 .SH 関連項目
107 \fBpthread_cancel\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
108 \fBpthread_exit\fP(3), \fBpthread_tryjoin_np\fP(3), \fBpthreads\fP(7)
109 .SH この文書について
110 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
111 である。プロジェクトの説明とバグ報告に関する情報は
112 http://www.kernel.org/doc/man\-pages/ に書かれている。