OSDN Git Service

Retire LDP man-pages repository
[linuxjm/LDP_man-pages.git] / draft / man3 / system.3
diff --git a/draft/man3/system.3 b/draft/man3/system.3
deleted file mode 100644 (file)
index f4f88e7..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
-.\" and Copyright (c) 2014 by Michael Kerrisk <mtk.manpages@gmail.com>
-.\"
-.\" %%%LICENSE_START(VERBATIM)
-.\" Permission is granted to make and distribute verbatim copies of this
-.\" manual provided the copyright notice and this permission notice are
-.\" preserved on all copies.
-.\"
-.\" Permission is granted to copy and distribute modified versions of this
-.\" manual under the conditions for verbatim copying, provided that the
-.\" entire resulting derived work is distributed under the terms of a
-.\" permission notice identical to this one.
-.\"
-.\" Since the Linux kernel and libraries are constantly changing, this
-.\" manual page may be incorrect or out-of-date.  The author(s) assume no
-.\" responsibility for errors or omissions, or for damages resulting from
-.\" the use of the information contained herein.  The author(s) may not
-.\" have taken the same level of care in the production of this manual,
-.\" which is licensed free of charge, as they might when working
-.\" professionally.
-.\"
-.\" Formatted or processed versions of this manual, if unaccompanied by
-.\" the source, must acknowledge the copyright and authors of this work.
-.\" %%%LICENSE_END
-.\"
-.\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu)
-.\" Modified 11 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
-.\" Modified 14 May 2001, 23 Sep 2001 by aeb
-.\" 2004-12-20, mtk
-.\"
-.\"*******************************************************************
-.\"
-.\" This file was generated with po4a. Translate the source file.
-.\"
-.\"*******************************************************************
-.\"
-.\" Japanese Version Copyright (c) 1996 Shoichi OZAWA
-.\"    all right reserved.
-.\" Translated 1996-09-01, Shoichi OZAWA <ozawa@omika.hitachi.co.jp>
-.\" Updated 2001-03-19, Kentaro Shirakata <argrath@ub32.org>
-.\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
-.\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\"
-.TH SYSTEM 3 2014\-06\-13 "" "Linux Programmer's Manual"
-.SH 名前
-system \- シェルコマンドの実行
-.SH 書式
-.nf
-\fB#include <stdlib.h>\fP
-.sp
-\fBint system(const char *\fP\fIcommand\fP\fB);\fP
-.fi
-.SH 説明
-\fBsystem\fP() ライブラリ関数は、\fBfork\fP(2) を使って子プロセスを作成し、その子プロセスは以下のように \fIcommand\fP
-で指定されたシェルコマンドを \fBexecl\fP(3) を使って実行する。
-
-    execl("/bin/sh", "sh", "\-c", command, (char *) 0);
-
-\fBsystem\fP() が返るのはコマンドが完了した後である。
-
-コマンドの実行中は、 \fBsystem\fP() を呼び出したプロセスでは、 \fBSIGCHLD\fP はブロックされ、 \fBSIGINT\fP と
-\fBSIGQUIT\fP は無視される (\fIcommand\fP を実行する子プロセスでは、これらのシグナルはデフォルトの処理方法にしたがって処理される)。
-
-\fIcommand\fP が NULL の場合、 \fBsystem\fP()  はそのシステムでシェルが利用可能かを示すステータスを返す。
-.SH 返り値
-\fBsystem\fP() の返り値は以下のいずれかである。
-.IP * 3
-\fIcommand\fP が NULL の場合、 シェルが利用可能ならゼロ以外の値、利用不可なら 0。
-.IP *
-子プロセスを作成できなかった場合、または子プロセスのステータスを取得できなかった場合、 返り値は \-1 である。
-.IP *
-子プロセスでシェルを実行できなかった場合、 返り値は子プロセスがステータス 127 で \fB_exit\fP(2) を呼び出して終了したのと同じになる。
-.IP *
-システムコールがすべて成功した場合、 返り値は \fIcommand\fP を実行するのに使用された子プロセスのシェルの終了ステータスとなる
-(シェルの終了ステータスはそのシェルが実行した最後のコマンドの終了ステータスである)。
-.PP
-最後の 2 つの場合、返り値は "wait status" であり、 \fBwaitpid\fP(2) に書かれているマクロ (つまり
-\fBWIFEXITED\fP() や \fBWEXITSTATUS\fP() などのマクロ) を使って検査することができる。
-.PP
-\fBsystem\fP()  は他の子プロセスのウエイトステータスには影響を与えない。
-.SH 属性
-.SS "マルチスレッディング (pthreads(7) 参照)"
-関数 \fBsystem\fP() はスレッドセーフである。
-.SH 準拠
-C89, C99, POSIX.1\-2001.
-.SH 注意
-\fBsystem\fP() により簡便性と利便性がもたらされる。この関数は \fBfork\fP(2), \fBexecl\fP(3), \fBwaitpid\fP(2)
-の呼び出しにおける詳細をすべて行うとともに、 シグナルの適切な処理も行う。 また、シェルは \fIcommand\fP に対して通常の置換
-(substitutions) と I/O リダイレクトを行う。 \fBsystem\fP() を使用することによる主なコストは非効率性である。
-シェルを実行するプロセスを作成するためとそのシェルを実行するために、余計にシステムコールが必要となる。
-
-(「どの」ヘッダーファイルをインクルードするよりも前に)  機能検査マクロ \fB_XOPEN_SOURCE\fP が定義された場合には、
-\fBwaitpid\fP(2)  で説明されているマクロ群 (\fBWEXITSTATUS\fP()  等) が \fI<stdlib.h>\fP
-をインクルードすると利用可能になる。
-.PP
-既に述べたように、 \fBsystem\fP()  は \fBSIGINT\fP と \fBSIGQUIT\fP を無視する。 よってループから \fBsystem\fP()
-を呼ぶプログラムは、 以下の例のように子プロセスの終了状態を自分でチェックしておかないと、 中断できなくなるかもしれない。
-.br
-.nf
-
-    while (something) {
-        int ret = system("foo");
-
-        if (WIFSIGNALED(ret) &&
-            (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
-                break;
-    }
-.fi
-.PP
-set\-user\-ID や set\-group\-ID の特権をもつプログラムの中では \fBsystem\fP()
-を使ってはいけない。なぜなら、ある環境変数の未知の値によって システムの安全が損なわれるからである。代わりに \fBexec\fP(3)  関連の関数群の中で
-\fBexeclp\fP(3)  と \fBexecvp\fP(3)  以外の関数を使用すべきである。 実際のところ、 \fBsystem\fP()  は
-\fI/bin/sh\fP が bash バージョン 2 であるシステムでは、 set\-user\-ID や set\-group\-ID
-の特権を持つプログラムからは正しく動作しない。 なぜなら、bash バージョン 2 はスタートアップ時に特権を落とすからである。 (Debian
-では、sh として起動された時にはこのような動作を行なわないように 修正された bash を用いている)
-.PP
-glibc 2.1.3 より前のバージョンでは、 \fIcommand\fP が NULL の場合に \fI/bin/sh\fP
-が利用可能かどうかのチェックは実際には行わず、 いつでも利用可能であるとみなしていた。 \fBsystem\fP()  はこの場合に常に 1 を返していた。
-POSIX.1\-2001 ではシェルが提供されているという標準に準拠した実装を 要求しているが、glibc 2.1.3
-以降ではシェルのチェックを実行している。 なぜなら、呼び出し元のプログラムが \fBsystem\fP()  を呼び出すより前に (POSIX.1\-2001
-では規定されていない)  \fBchroot\fP(2)  を呼び出していた時には、シェルが利用可能でない場合や実行可能ファイル でない場合があるからである。
-.PP
-シェルコマンドがステータス 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.79 の一部
-である。プロジェクトの説明とバグ報告に関する情報は
-http://www.kernel.org/doc/man\-pages/ に書かれている。