OSDN Git Service

003182442eb8544c0e720f0f7ff69c280be1b0fc
[linuxjm/LDP_man-pages.git] / release / man3 / pthread_exit.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 .TH PTHREAD_EXIT 3 2009\-03\-30 Linux "Linux Programmer's Manual"
32 .SH 名前
33 pthread_exit \- 呼び出したスレッドを終了する
34 .SH 書式
35 .nf
36 \fB#include <pthread.h>\fP
37
38 \fBvoid pthread_exit(void *\fP\fIretval\fP\fB);\fP
39 .sp
40 \fI\-pthread\fP でコンパイルしてリンクする。
41 .fi
42 .SH 説明
43 \fBpthread_exit\fP() 関数は、呼び出したスレッドを終了し、
44 \fIretval\fP 経由で値を返す。
45 この値は (そのスレッドが join 可能な場合に) \fBpthread_join\fP(3) を
46 呼び出した同じプロセス内の別のスレッドが参照できる値と同じである。
47
48 \fBpthread_cleanup_push\fP(3) で設定されたクリーンアップハンドラのうち、
49 まだ pop (取り出されていない) ハンドラを (push されたのと逆の順序で)
50 取り出して実行する。そのスレッドがスレッド固有のデータを持っている
51 場合は、クリーンアップハンドラが実行された後に、スレッド固有のデータ
52 に対応するデストラクタ (destructor) 関数が呼び出される (呼び出し順序
53 は規定されていない)。
54
55 スレッドが終了する際に、プロセスの共有リソース (例えば、mutex、状態変数
56 (condition variables)、セマフォ、ファイルディスクリプタ)が解放される。
57 \fBatexit\fP(3) を使って登録された関数は呼び出されない。
58
59 プロセスの最後のスレッドが終了すると、そのプロセスは、終了ステータス 0
60 で \fBexit\fP(3) を呼び出した場合と全く同じように終了する。したがって、
61 プロセスの共有リソースは解放され、\fBatexit\fP(3) を使って登録された関数
62 が呼び出される。
63 .SH 返り値
64 この関数は呼び出し側には返らない。
65 .SH エラー
66 この関数は常に成功する。
67 .SH 準拠
68 POSIX.1\-2001.
69 .SH 注意
70 メインスレッド以外のスレッドの開始関数 (start function) がreturn を
71 行うと、暗黙のうちに \fBpthread_exit\fP() が呼び出され、
72 関数の返り値がスレッドの終了ステータスとして使用される。
73
74 他のスレッドが実行を継続できるように、メインスレッドは \fBexit\fP(3) では
75 なく \fBpthread_exit\fP() を呼び出して終了すべきである。
76
77 \fIretval\fP が指す値は、呼び出したスレッドのスタックに置くべきではない。
78 呼び出したスレッドが終了した後は、そのスタックの内容が不定となるから
79 である。
80 .SH バグ
81 .\" Linux 2.6.27
82 .\" FIXME . review a later kernel to see if this gets fixed
83 .\" http://thread.gmane.org/gmane.linux.kernel/611611
84 .\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2
85 現在のところ、停止 (stop) されたスレッドグループを、すでに終了した
86 (dead) スレッドグループリーダーで \fBwait\fP(2) する場合の、
87 カーネル実装の論理には制限がある。
88 この制限は、すでにスレッドグループリーダーが \fBpthread_exit\fP() を
89 呼び出しているようなフォアグラウンドプロセスにストップシグナルが送信
90 された場合に、端末がロックされてしまう、といった問題として表に見える
91 場合がある。
92 .SH 関連項目
93 \fBpthread_create\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7)
94 .SH この文書について
95 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
96 である。プロジェクトの説明とバグ報告に関する情報は
97 http://www.kernel.org/doc/man\-pages/ に書かれている。