\fBpopen\fP(), \fBpclose\fP():
.RS 4
_POSIX_C_SOURCE\ >=\ 2
- || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
+ || /* glibc 2.19 以前: */ _BSD_SOURCE || _SVID_SOURCE
.RE
.ad b
.SH 説明
定義から分かるように、パイプは一方向なので、 \fItype\fP 引き数には読み込みか書き込みのどちらか一方だけを指定できる (両方は指定できない)。
生成されるストリームは、この指定に対応して、読み取り専用または 書き込み専用のいずれかとなる。
.PP
-The \fIcommand\fP argument is a pointer to a null\-terminated string containing
-a shell command line. This command is passed to \fI/bin/sh\fP using the \fB\-c\fP
-flag; interpretation, if any, is performed by the shell.
+\fIcommand\fP 引き数は、シェルのコマンドラインを含むヌル終端された文字列へのポインターである。 このコマンドは \fB\-c\fP フラグを用いて
+\fI/bin/sh\fP に渡される。 コマンドの解釈は (もし必要ならば) シェルによって行われる。
.PP
-The \fItype\fP argument is a pointer to a null\-terminated string which must
-contain either the letter \(aqr\(aq for reading or the letter \(aqw\(aq for
-writing. Since glibc 2.9, this argument can additionally include the letter
-\(aqe\(aq, which causes the close\-on\-exec flag (\fBFD_CLOEXEC\fP) to be set on
-the underlying file descriptor; see the description of the \fBO_CLOEXEC\fP flag
-in \fBopen\fP(2) for reasons why this may be useful.
+\fItype\fP 引き数は、ヌル終端された文字列へのポインターで、 読み込みを示す文字 \(aqr\(aq か、書き込みを示す文字 \(aqw\(aq の
+どちらか一方を指定しなければならない。 glibc 2.9 以降では、この引き数に文字 \(aqe\(aq を追加で指定できる。 文字
+\(aqe\(aq を指定すると、 対応するファイルディスクリプターにおいて、 close\-on\-exec フラグ (\fBFD_CLOEXEC\fP)
+がセットされる。 これが役に立つ理由については、 \fBopen\fP(2) の \fBO_CLOEXEC\fP フラグの説明を参照のこと。
.PP
\fBpopen\fP() からの返り値は、通常の標準 I/O ストリームと同じであるが、 \fBfclose\fP(3) ではなく \fBpclose\fP()
で閉じなくてはならないことだけが異なる。 このストリームへ書き込んだ結果はコマンドの標準入力に書き込まれる。 そして、コマンドの標準出力は、
ストリームからの読み込みは、 そのコマンドの標準出力を読み込むことになる。 そして、そのコマンドの標準入力は \fBpopen\fP()
を呼んだプロセスの標準入力と同一である。
.PP
-Note that output \fBpopen\fP() streams are block buffered by default.
+デフォルトでは、 \fBpopen\fP() の出力ストリームは block buffered であることに注意すること。
.PP
\fBpclose\fP() 関数は、(パイプに) 関連づけられたプロセスが終了するのを待ち、 \fBwait4\fP(2)
によって返されたコマンドの終了状態を返す。