-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" Copyright (C) 2005, 2008, Michael Kerrisk <mtk.manpages@gmail.com>
.\" (A few fragments remain from an earlier (1992) version by
.\" Drew Eckhardt <drew@cs.colorado.edu>.)
.\"
+.\" %%%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.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
.\" to EXAMPLE text.
.\" 2008-10-10, mtk: add description of pipe2()
.\"
-.\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
-.\" all rights reserved.
-.\" Translated Thu Jun 26 21:09:51 JST 1997
-.\" by SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
-.\" Updated & Modified Thu Feb 10 00:47:11 JST 2005
-.\" by Yuichi SATO <ysato444@yahoo.co.jp>
-.\" Updated & Modified Sat Dec 17 08:10:16 JST 2005 by Yuichi SATO
-.\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
-.\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.13
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
.\"
-.TH PIPE 2 2010-09-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
+.\"*******************************************************************
+.TH PIPE 2 2012\-02\-14 Linux "Linux Programmer's Manual"
.SH 名前
-.\"O pipe, pipe2 \- create pipe
pipe, pipe2 \- パイプを生成する
-.\"O .SH SYNOPSIS
.SH 書式
.nf
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
.sp
-.BI "int pipe(int " pipefd "[2]);"
+\fBint pipe(int \fP\fIpipefd\fP\fB[2]);\fP
.sp
-.\"O .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
-.BR "#define _GNU_SOURCE" " /* feature_test_macros(7) 参照 */"
-.B #include <unistd.h>
+\fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */
+\fB#include <fcntl.h>\fP /* O_* 定数の定義の取得 */
+\fB#include <unistd.h>\fP
.sp
-.BI "int pipe2(int " pipefd "[2], int " flags );
+\fBint pipe2(int \fP\fIpipefd\fP\fB[2], int \fP\fIflags\fP\fB);\fP
.fi
-.\"O .SH DESCRIPTION
.SH 説明
-.\"O .BR pipe ()
-.\"O creates a pipe, a unidirectional data channel that
-.\"O can be used for interprocess communication.
-.\"O The array
-.\"O .IR pipefd
-.\"O is used to return two file descriptors referring to the ends of the pipe.
-.\"O .IR pipefd[0]
-.\"O refers to the read end of the pipe.
-.\"O .IR pipefd[1]
-.\"O refers to the write end of the pipe.
-.\"O Data written to the write end of the pipe is buffered by the kernel
-.\"O until it is read from the read end of the pipe.
-.\"O For further details, see
-.\"O .BR pipe (7).
-.BR pipe (2)
-はパイプを生成する。
-パイプは、プロセス間通信に使用できる単方向のデータチャネルである。
-配列
-.I pipefd
-は、パイプの両端を参照する二つのファイルディスクリプタを
-返すのに使用される。
-.I pipefd[0]
-がパイプの読み出し側、
-.I pipefd[1]
-がパイプの書き込み側である。
-パイプの書き込み側に書き込まれたデータは、
-パイプの読み出し側から読み出されるまでカーネルでバッファリングされる。
-さらなる詳細は
-.BR pipe (7)
-を参照のこと。
+\fBpipe\fP(2) はパイプを生成する。 パイプは、プロセス間通信に使用できる単方向のデータチャネルである。 配列 \fIpipefd\fP
+は、パイプの両端を参照する二つのファイルディスクリプタを 返すのに使用される。 \fIpipefd[0]\fP がパイプの読み出し側、
+\fIpipefd[1]\fP がパイプの書き込み側である。 パイプの書き込み側に書き込まれたデータは、
+パイプの読み出し側から読み出されるまでカーネルでバッファリングされる。 さらなる詳細は \fBpipe\fP(7) を参照のこと。
-.\"O If
-.\"O .IR flags
-.\"O is 0, then
-.\"O .BR pipe2 ()
-.\"O is the same as
-.\"O .BR pipe ().
-.\"O The following values can be bitwise ORed in
-.\"O .IR flags
-.\"O to obtain different behavior:
-.BR pipe2 ()
-は
-.I flags
-が 0 の場合には
-.BR pipe ()
-と同じである。
-.I flags
-に以下の値をビット毎の論理和 (OR) で指定することで、
-異なる動作をさせることができる。
-.TP 12
-.B O_NONBLOCK
-.\"O Set the
-.\"O .BR O_NONBLOCK
-.\"O file status flag on the two new open file descriptions.
-.\"O Using this flag saves extra calls to
-.\"O .BR fcntl (2)
-.\"O to achieve the same result.
-新しく生成される二つのオープンファイル記述 (open file description) の
-.B O_NONBLOCK
-ファイルステータスフラグをセットする。
-このフラグを使うことで、
-.B O_NONBLOCK
-をセットするために
-.BR fcntl (2)
+\fBpipe2\fP() は \fIflags\fP が 0 の場合には \fBpipe\fP() と同じである。 \fIflags\fP に以下の値をビット毎の論理和
+(OR) で指定することで、 異なる動作をさせることができる。
+.TP 12
+\fBO_NONBLOCK\fP
+新しく生成される二つのオープンファイル記述 (open file description) の \fBO_NONBLOCK\fP
+ファイルステータスフラグをセットする。 このフラグを使うことで、 \fBO_NONBLOCK\fP をセットするために \fBfcntl\fP(2)
を追加で呼び出す必要がなくなる。
-.TP
-.B O_CLOEXEC
-.\"O Set the close-on-exec
-.\"O .RB ( FD_CLOEXEC )
-.\"O flag on the two new file descriptors.
-.\"O See the description of the same flag in
-.\"O .BR open (2)
-.\"O for reasons why this may be useful.
-新しく生成される二つのファイルディスクリプタの
-close-on-exec
-.RB ( FD_CLOEXEC )
-フラグをセットする。
-このフラグが役に立つ理由については、
-.BR open (2)
-の
-.B O_CLOEXEC
-フラグの説明を参照のこと。
-.\"O .SH "RETURN VALUE"
+.TP
+\fBO_CLOEXEC\fP
+新しく生成される二つのファイルディスクリプタの close\-on\-exec (\fBFD_CLOEXEC\fP) フラグをセットする。
+このフラグが役に立つ理由については、 \fBopen\fP(2) の \fBO_CLOEXEC\fP フラグの説明を参照のこと。
.SH 返り値
-.\"O On success, zero is returned.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-成功した場合 0 が返る。失敗した場合 \-1 が返り、
-.I errno
-がエラーの内容に従って設定される。
-.\"O .SH ERRORS
+成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
.SH エラー
-.TP
-.B EFAULT
-.\"O .I pipefd
-.\"O is not valid.
-.I pipefd
-が無効な値である。
-.TP
-.B EINVAL
-.\"O .RB ( pipe2 ())
-.\"O Invalid value in
-.\"O .IR flags .
-.RB ( pipe2 ())
-.I flags
-に無効な値が入っている。
-.TP
-.B EMFILE
-.\"O Too many file descriptors are in use by the process.
+.TP
+\fBEFAULT\fP
+\fIpipefd\fP が無効な値である。
+.TP
+\fBEINVAL\fP
+(\fBpipe2\fP()) \fIflags\fP に無効な値が入っている。
+.TP
+\fBEMFILE\fP
このプロセスで使われているファイルディスクリプタが多すぎる。
-.TP
-.B ENFILE
-.\"O The system limit on the total number of open files has been reached.
-オープンされているファイルの総数がシステムの制限に達した。
-.\"O .SH VERSIONS
+.TP
+\fBENFILE\fP
+オープンされているファイルの総数がシステムの制限に達している。
.SH バージョン
-.\"O .BR pipe2 ()
-.\"O was added to Linux in version 2.6.27;
-.\"O glibc support is available starting with
-.\"O version 2.9.
-.BR pipe2 ()
-はバージョン 2.6.27 で Linux に追加された。
-glibc によるサポートはバージョン 2.9 以降で利用できる。
-.\"O .SH "CONFORMING TO"
+\fBpipe2\fP() はバージョン 2.6.27 で Linux に追加された。 glibc によるサポートはバージョン 2.9 以降で利用できる。
.SH 準拠
-.BR pipe ():
-POSIX.1-2001.
+\fBpipe\fP(): POSIX.1\-2001.
-.\"O .BR pipe2 ()
-.\"O is Linux-specific.
-.BR pipe2 ()
-は Linux 固有である。
-.\"O .SH EXAMPLE
+\fBpipe2\fP() は Linux 固有である。
.SH 例
-.\"O .\" fork.2 refers to this example program.
-.\" fork.2 はこの例のプログラムを参照している。
-.\"O The following program creates a pipe, and then
-.\"O .BR fork (2)s
-.\"O to create a child process;
-.\"O the child inherits a duplicate set of file
-.\"O descriptors that refer to the same pipe.
-以下のプログラムではパイプを生成し、その後
-.BR fork (2)
-で子プロセスを生成する。
-子プロセスは同じパイプを参照するファイルディスクリプタ集合のコピーを
-継承する。
-.\"O After the
-.\"O .BR fork (2),
-.\"O each process closes the descriptors that it doesn't need for the pipe
-.\"O (see
-.\"O .BR pipe (7)).
-.BR fork (2)
-の後、各プロセスはパイプ
-.RB ( pipe (7)
-を参照) に必要がなくなったディスクリプタをクローズする。
-.\"O The parent then writes the string contained in the program's
-.\"O command-line argument to the pipe,
-.\"O and the child reads this string a byte at a time from the pipe
-.\"O and echoes it on standard output.
-親プロセスはプログラムのコマンドライン引き数に含まれる
-文字列をパイプへ書き込み、
-子プロセスはこの文字列をパイプから 1 バイトずつ読み込んで標準出力にエコーする。
+.\" fork.2 refers to this example program.
+以下のプログラムではパイプを生成し、その後 \fBfork\fP(2) で子プロセスを生成する。
+子プロセスは同じパイプを参照するファイルディスクリプタ集合のコピーを 継承する。 \fBfork\fP(2) の後、各プロセスはパイプ
+(\fBpipe\fP(7) を参照) に必要がなくなったディスクリプタをクローズする。 親プロセスはプログラムのコマンドライン引き数に含まれる
+文字列をパイプへ書き込み、 子プロセスはこの文字列をパイプから 1 バイトずつ読み込んで標準出力にエコーする。
.nf
#include <sys/wait.h>
char buf;
if (argc != 2) {
- fprintf(stderr, "Usage: %s <string>\\n", argv[0]);
+ fprintf(stderr, "Usage: %s <string>\en", argv[0]);
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
-.\"O if (cpid == 0) { /* Child reads from pipe */
if (cpid == 0) { /* 子プロセスがパイプから読み込む */
-.\"O close(pipefd[1]); /* Close unused write end */
close(pipefd[1]); /* 使用しない write 側はクローズする */
while (read(pipefd[0], &buf, 1) > 0)
write(STDOUT_FILENO, &buf, 1);
- write(STDOUT_FILENO, "\\n", 1);
+ write(STDOUT_FILENO, "\en", 1);
close(pipefd[0]);
_exit(EXIT_SUCCESS);
-.\"O } else { /* Parent writes argv[1] to pipe */
-.\"O close(pipefd[0]); /* Close unused read end */
-.\"O write(pipefd[1], argv[1], strlen(argv[1]));
-.\"O close(pipefd[1]); /* Reader will see EOF */
-.\"O wait(NULL); /* Wait for child */
} else { /* 親プロセスは argv[1] をパイプへ書き込む */
close(pipefd[0]); /* 使用しない read 側はクローズする */
write(pipefd[1], argv[1], strlen(argv[1]));
}
}
.fi
-.\"O .SH "SEE ALSO"
.SH 関連項目
-.BR fork (2),
-.BR read (2),
-.BR socketpair (2),
-.BR write (2),
-.BR popen (3),
-.BR pipe (7)
+\fBfork\fP(2), \fBread\fP(2), \fBsocketpair\fP(2), \fBwrite\fP(2), \fBpopen\fP(3),
+\fBpipe\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。