1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" Modified 11 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
25 .\" Modified 14 May 2001, 23 Sep 2001 by aeb
28 .\" Japanese Version Copyright (c) 1996 Shoichi OZAWA
29 .\" all right reserved.
30 .\" Translated 1996-09-01, Shoichi OZAWA <ozawa@omika.hitachi.co.jp>
31 .\" Updated 2001-03-19, Kentaro Shirakata <argrath@ub32.org>
32 .\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
33 .\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\"WORD: feature test macro 機能検査マクロ
37 .TH SYSTEM 3 2010-09-10 "" "Linux Programmer's Manual"
42 .B #include <stdlib.h>
44 .BI "int system(const char *" "command" );
53 の形で実行する。指定したコマンドが終了すればこの関数も終了する。
65 そうでなければ、コマンドのステータスを返す。
70 .I WEXITSTATUS(status)
81 はシェルが利用可能ならゼロ以外の値を返し、利用不可ならゼロを返す。
84 は他の子プロセスのウエイトステータスには影響を与えない。
86 C89, C99, POSIX.1-2001.
89 (「どの」ヘッダファイルをインクルードするよりも前に)
110 以下の例のように子プロセスの終了状態を自分でチェックしておかないと、
116 int ret = system("foo");
118 if (WIFSIGNALED(ret) &&
119 (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
124 set-user-ID や set-group-ID の特権をもつプログラムの中では
126 を使ってはいけない。なぜなら、ある環境変数の未知の値によって
127 システムの安全が損なわれるからである。代わりに
138 が bash バージョン 2 であるシステムでは、
139 set-user-ID や set-group-ID の特権を持つプログラムからは正しく動作しない。
140 なぜなら、bash バージョン 2 はスタートアップ時に特権を落とすからである。
141 (Debian では、sh として起動された時にはこのような動作を行なわないように
144 glibc 2.1.3 より前のバージョンでは、
148 が利用可能かどうかのチェックは実際には行わず、
152 POSIX.1-2001 ではシェルが提供されているという標準に準拠した実装を
153 要求しているが、glibc 2.1.3 以降ではシェルのチェックを実行している。
156 を呼び出すより前に (POSIX.1-2001 では規定されていない)
158 を呼び出していた時には、シェルが利用可能でない場合や実行可能ファイル
163 の呼び出しに失敗した時に返す値) を返すことも考えられる。
164 そのため、プログラムは (リターンコードを見るだけでは)
166 の呼び出しが失敗したことを確実に知ることはできない。