OSDN Git Service

2cb071ed5eabcd01b4c518162b9d4cb6fe673136
[linuxjm/jm.git] / manual / LDP_man-pages / 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 2020\-06\-09 Linux "Linux Programmer's Manual"
37 .SH 名前
38 pthread_join \- 終了したスレッドを join する
39 .SH 書式
40 .nf
41 \fB#include <pthread.h>\fP
42 .PP
43 \fBint pthread_join(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB);\fP
44 .fi
45 .PP
46 \fI\-pthread\fP を付けてコンパイルとリンクを行う。
47 .SH 説明
48 \fBpthread_join\fP() 関数は、\fIthread\fP で指定されたスレッドが
49 終了するのを待つ。そのスレッドがすでに終了している場合、
50 \fBpthread_join\fP() はすぐに返る。
51 \fIthread\fP で指定されたスレッドは join 可能でなければならない。
52 .PP
53 If \fIretval\fP is not NULL, then \fBpthread_join\fP()  copies the exit status of
54 the target thread (i.e., the value that the target thread supplied to
55 \fBpthread_exit\fP(3))  into the location pointed to by \fIretval\fP.  If the
56 target thread was canceled, then \fBPTHREAD_CANCELED\fP is placed in the
57 location pointed to by \fIretval\fP.
58 .PP
59 複数のスレッドが同時に同じスレッドを join しようとした場合、その結果
60 は不定である。\fBpthread_join\fP() を呼び出しているスレッドがキャンセル
61 された場合、対象スレッドは join 可能のままとなる (detached 状態には
62 ならない)。
63 .SH 返り値
64 成功すると、 \fBpthread_join\fP() は 0 を返す。
65 エラーの場合、エラー番号を返す。
66 .SH エラー
67 .TP 
68 \fBEDEADLK\fP
69 .\" The following verified by testing on glibc 2.8/NPTL:
70 .\" The following verified by testing on glibc 2.8/NPTL:
71 デッドロックが検出された (例えば、二つのスレッドが互いに join しようと
72 した場合)、または \fIthread\fP に呼び出したスレッドが指定されている。
73 .TP 
74 \fBEINVAL\fP
75 \fIthread\fP が join 可能なスレッドではない。
76 .TP 
77 \fBEINVAL\fP
78 .\" POSIX.1-2001 does not specify this error case.
79 別のスレッドがすでにこのスレッドの join 待ちである。
80 .TP 
81 \fBESRCH\fP
82 ID が \fIthread\fP のスレッドが見つからなかった。
83 .SH 属性
84 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
85 .TS
86 allbox;
87 lb lb lb
88 l l l.
89 インターフェース        属性  値
90 T{
91 \fBpthread_join\fP()
92 T}      Thread safety   MT\-Safe
93 .TE
94 .sp 1
95 .SH 準拠
96 POSIX.1\-2001, POSIX.1\-2008.
97 .SH 注意
98 After a successful call to \fBpthread_join\fP(), the caller is guaranteed that
99 the target thread has terminated.  The caller may then choose to do any
100 clean\-up that is required after termination of the thread (e.g., freeing
101 memory or other resources that were allocated to the target thread).
102 .PP
103 すでに join されたスレッドを join した場合の結果は不定である。
104 .PP
105 join 可能なスレッド (detached 状態でないスレッド) の join に失敗した場合、
106 "ゾンビスレッド (zombie thread)" が生成される。
107 各ゾンビスレッドはシステムリソースをいくらかは消費し、
108 ゾンビスレッドがたくさん生成されてしまうと、
109 新しいスレッド (やプロセス) がそれ以上作成できなくなってしまうので、
110 このようなことが起きるのは避けること。
111 .PP
112 pthreads には、 \fIwaitpid(\-1,\ &status,\ 0)\fP、つまり
113 "終了されたスレッドのどれかを join する" といった機能はない。
114 この機能が必要だと思うような場合には、おそらく
115 自分のアプリケーションの設計を考え直す必要があるだろう。
116 .PP
117 プロセス内の全てのスレッドは対等であり、
118 どのスレッドでもプロセス内の他のスレッドを join できる。
119 .SH EXAMPLES
120 \fBpthread_create\fP(3) を参照。
121 .SH 関連項目
122 \fBpthread_cancel\fP(3), \fBpthread_create\fP(3), \fBpthread_detach\fP(3),
123 \fBpthread_exit\fP(3), \fBpthread_tryjoin_np\fP(3), \fBpthreads\fP(7)
124 .SH この文書について
125 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
126 \%https://www.kernel.org/doc/man\-pages/ に書かれている。