.\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
-.TH SYSTEM 3 2014\-05\-10 "" "Linux Programmer's Manual"
+.TH SYSTEM 3 2014\-06\-13 "" "Linux Programmer's Manual"
.SH 名前
system \- シェルコマンドの実行
.SH 書式
\fBsystem\fP() ライブラリ関数は、\fBfork\fP(2) を使って子プロセスを作成し、その子プロセスは以下のように \fIcommand\fP
で指定されたシェルコマンドを \fBexecl\fP(3) を使って実行する。
- execl("/bin/sh", "sh". "\-c", command, (char *) 0);
+ execl("/bin/sh", "sh", "\-c", command, (char *) 0);
\fBsystem\fP() が返るのはコマンドが完了した後である。
\fBWIFEXITED\fP() や \fBWEXITSTATUS\fP() などのマクロ) を使って検査することができる。
.PP
\fBsystem\fP() は他の子プロセスのウエイトステータスには影響を与えない。
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+関数 \fBsystem\fP() はスレッドセーフである。
.SH 準拠
C89, C99, POSIX.1\-2001.
.SH 注意
-\fBsystem\fP() provides simplicity and convenience: it handles all of the
-details of calling \fBfork\fP(2), \fBexecl\fP(3), and \fBwaitpid\fP(2), as well as
-the necessary manipulations of signals; in addition, the shell performs the
-usual substitutions and I/O redirections for \fIcommand\fP. The main cost of
-\fBsystem\fP() is inefficiency: additional system calls are required to create
-the process that runs the shell and to execute the shell.
+\fBsystem\fP() により簡便性と利便性がもたらされる。この関数は \fBfork\fP(2), \fBexecl\fP(3), \fBwaitpid\fP(2)
+の呼び出しにおける詳細をすべて行うとともに、 シグナルの適切な処理も行う。 また、シェルは \fIcommand\fP に対して通常の置換
+(substitutions) と I/O リダイレクトを行う。 \fBsystem\fP() を使用することによる主なコストは非効率性である。
+シェルを実行するプロセスを作成するためとそのシェルを実行するために、余計にシステムコールが必要となる。
-(「どの」ヘッダファイルをインクルードするよりも前に) 機能検査マクロ \fB_XOPEN_SOURCE\fP が定義された場合には、
+(ã\80\8cã\81©ã\81®ã\80\8dã\83\98ã\83\83ã\83\80ã\83¼ã\83\95ã\82¡ã\82¤ã\83«ã\82\92ã\82¤ã\83³ã\82¯ã\83«ã\83¼ã\83\89ã\81\99ã\82\8bã\82\88ã\82\8aã\82\82å\89\8dã\81«) æ©\9fè\83½æ¤\9cæ\9f»ã\83\9eã\82¯ã\83 \fB_XOPEN_SOURCE\fP ã\81\8cå®\9a義ã\81\95ã\82\8cã\81\9få ´å\90\88ã\81«ã\81¯ã\80\81
\fBwaitpid\fP(2) で説明されているマクロ群 (\fBWEXITSTATUS\fP() 等) が \fI<stdlib.h>\fP
をインクルードすると利用可能になる。
.PP
以降ではシェルのチェックを実行している。 なぜなら、呼び出し元のプログラムが \fBsystem\fP() を呼び出すより前に (POSIX.1\-2001
では規定されていない) \fBchroot\fP(2) を呼び出していた時には、シェルが利用可能でない場合や実行可能ファイル でない場合があるからである。
.PP
-It is possible for the shell command to terminate with a status of 127,
-which yields a \fBsystem\fP() return value that is indistinguishable from the
-case where a shell could not be executed in the child process.
+シェルコマンドがステータス 127 で終了することもある。 この場合、\fBsystem\fP()
+の返り値は、子プロセスでシェルが実行できなかった場合と区別できない。
.SH 関連項目
\fBsh\fP(1), \fBsigaction\fP(2), \fBsigprocmask\fP(2), \fBfork\fP(2), \fBwait\fP(2),
\fBexec\fP(3), \fBsignal\fP(7)
.SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.68 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.78 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。