OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man2 / wait4.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
4 .\" and Copyright (c) 2004 by Michael Kerrisk (mtk.manpages@gmail.com)
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" License.
26 .\"
27 .\" Modified Sat Jul 24 13:32:44 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
29 .\" Modified Tue Jul  7 12:26:42 1998 by aeb - changed return value wait3
30 .\" Modified 2004-11-11, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Rewrote much of this page, and removed much duplicated text,
32 .\"             replacing with pointers to wait.2
33 .\"
34 .\"*******************************************************************
35 .\"
36 .\" This file was generated with po4a. Translate the source file.
37 .\"
38 .\"*******************************************************************
39 .TH WAIT4 2 2010\-09\-20 Linux "Linux Programmer's Manual"
40 .SH 名前
41 wait3, wait4 \- BSD スタイルでプロセスの状態変化を待つ
42 .SH 書式
43 .nf
44 \fB#include <sys/types.h>\fP
45 \fB#include <sys/time.h>\fP
46 \fB#include <sys/resource.h>\fP
47 \fB#include <sys/wait.h>\fP
48 .sp
49 \fBpid_t wait3(int *\fP\fIstatus\fP\fB, int \fP\fIoptions\fP\fB,\fP
50 \fB            struct rusage *\fP\fIrusage\fP\fB);\fP
51 .sp
52 \fBpid_t wait4(pid_t \fP\fIpid\fP\fB, int *\fP\fIstatus\fP\fB, int \fP\fIoptions\fP\fB,\fP
53 \fB            struct rusage *\fP\fIrusage\fP\fB);\fP
54 .fi
55 .sp
56 .in -4n
57 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
58 .in
59 .sp
60 .ad l
61 \fBwait3\fP():
62 .RS 4
63 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
64 .RE
65 .br
66 \fBwait4\fP():
67 .RS 4
68 _BSD_SOURCE
69 .RE
70 .ad
71 .SH 説明
72 システムコール \fBwait3\fP()  と \fBwait4\fP()  は \fBwaitpid\fP(2)
73 と同様の動作をする。それに加え、子プロセスのリソース使用状況の情報を \fIrusage\fP が指す構造体に入れて返す。
74 .PP
75 \fIrusage\fP を使用する点を除けば、次の \fBwait3\fP()  の呼び出し
76 .nf
77
78     wait3(status, options, rusage);
79
80 .fi
81 は以下と等価である。
82 .nf
83
84     waitpid(\-1, status, options);
85
86 .fi
87 同様に、次の \fBwait4\fP()  の呼び出し
88 .nf
89
90     wait4(pid, status, options, rusage);
91
92 .fi
93 は以下と等価である。
94 .nf
95
96     waitpid(pid, status, options);
97
98 .fi
99 言い換えると、 \fBwait3\fP()  は全ての子プロセスを対象に待つが、 \fBwait4\fP()  では特定の子プロセス (複数可)
100 を選んで待つことができる。
101 .PP
102 \fIrusage\fP が NULL でない場合、 \fIrusage\fP が指す \fIrusage 構造体\fP には子プロセスのアカウント情報が格納される。
103 詳しくは \fBgetrusage\fP(2)  を参照のこと。
104 .SH 返り値
105 \fBwaitpid\fP(2)  と同様。
106 .SH エラー
107 \fBwaitpid\fP(2)  と同様。
108 .SH 準拠
109 4.3BSD.
110 .SH 注意
111 現在では \fI<sys/time.h>\fP をインクルードする必要はないが、インクルードしておくと 移植性を高めることができる (実際には
112 \fI<sys/resource.h>\fP で \fIrusage\fP 構造体が定義されているが、そのフィールドで使用されている
113 \fIstruct timeval\fP 型は \fI<sys/time.h>\fP で定義されている)。
114
115 Linux では、 \fBwait3\fP()  はライブラリ関数であり、 \fBwait4\fP()  システムコールを使って実装されている。
116 .SH 関連項目
117 \fBfork\fP(2), \fBgetrusage\fP(2), \fBsigaction\fP(2), \fBsignal\fP(2), \fBwait\fP(2),
118 \fBsignal\fP(7)