-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
.\" and Copyright (C) 2005, 2008 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.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Modified 1993-07-21, Rik Faith <faith@cs.unc.edu>
.\" Modified 1994-08-21, Michael Chastain <mec@shell.portal.com>:
.\" details for dup2().
.\" 2008-10-09, mtk: add description of dup3()
.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
.\" Japanese Version Copyright (c) 1996 Takeshi Ueno
.\" all rights reserved.
.\" Translated 1996-07-03, Takeshi Ueno <tueno@vio.co.jp>
.\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
.\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.13
.\"
-.TH DUP 2 2010-09-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.\"O dup, dup2, dup3 \- duplicate a file descriptor
+.TH DUP 2 2012\-02\-14 Linux "Linux Programmer's Manual"
.SH 名前
dup, dup2, dup3 \- ファイル・ディスクリプタを複製する
-.\"O .SH SYNOPSIS
.SH 書式
.nf
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
.sp
-.BI "int dup(int " oldfd );
-.BI "int dup2(int " oldfd ", int " newfd );
+\fBint dup(int \fP\fIoldfd\fP\fB);\fP
+\fBint dup2(int \fP\fIoldfd\fP\fB, int \fP\fInewfd\fP\fB);\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 dup3(int " oldfd ", int " newfd ", int " flags );
+\fBint dup3(int \fP\fIoldfd\fP\fB, int \fP\fInewfd\fP\fB, int \fP\fIflags\fP\fB);\fP
.fi
-.\"O .SH DESCRIPTION
.SH 説明
-.\"O These system calls create a copy of the file descriptor
-.\"O .IR oldfd .
-これらのシステムコールは、ファイル・ディスクリプタ
-.I oldfd
-の複製を作る。
+これらのシステムコールは、ファイル・ディスクリプタ \fIoldfd\fP の複製を作る。
-.\"O .BR dup ()
-.\"O uses the lowest-numbered unused descriptor for the new descriptor.
-.BR dup ()
-は最も小さい番号の未使用のディスクリプタを
-新しいディスクリプタとして使用する。
+\fBdup\fP() は最も小さい番号の未使用のディスクリプタを 新しいディスクリプタとして使用する。
-.\"O .BR dup2 ()
-.\"O .RI "makes " newfd " be the copy of " oldfd ", closing " newfd
-.\"O first if necessary, but note the following:
-.BR dup2 ()
-は
-.I newfd
-を
-.I oldfd
-の複製として作成する。
-必要であれば最初に
-.I newfd
-をクローズする。
+\fBdup2\fP() は \fInewfd\fP を \fIoldfd\fP の複製として作成する。 必要であれば最初に \fInewfd\fP をクローズする。
以下の点に注意すること。
.IP * 3
-.\"O If
-.\"O .I oldfd
-.\"O is not a valid file descriptor, then the call fails, and
-.\"O .I newfd
-.\"O is not closed.
-.I oldfd
-が有効なファイルディスクリプタでない場合、その呼び出しは失敗し、
-.I newfd
-はクローズされない。
+\fIoldfd\fP が有効なファイルディスクリプタでない場合、その呼び出しは失敗し、 \fInewfd\fP はクローズされない。
.IP *
-.\"O If
-.\"O .I oldfd
-.\"O is a valid file descriptor, and
-.\"O .I newfd
-.\"O has the same value as
-.\"O .IR oldfd ,
-.\"O then
-.\"O .BR dup2 ()
-.\"O does nothing, and returns
-.\"O .IR newfd .
-.I oldfd
-が有効なファイルディスクリプタで、
-.I newfd
-が
-.I oldfd
-と同じ値の場合、
-.BR dup2 ()
-は何もせず、
-.I newfd
-を返す。
+\fIoldfd\fP が有効なファイルディスクリプタで、 \fInewfd\fP が \fIoldfd\fP と同じ値の場合、 \fBdup2\fP() は何もせず、
+\fInewfd\fP を返す。
.PP
-.\"O After a successful return from one of these system calls,
-.\"O the old and new file descriptors may be used interchangeably.
-.\"O They refer to the same open file description (see
-.\"O .BR open (2))
-.\"O and thus share file offset and file status flags;
-.\"O for example, if the file offset is modified by using
-.\"O .BR lseek (2)
-.\"O on one of the descriptors, the offset is also changed for the other.
-これらのシステムコールのいずれかが成功を返した場合には、
-古いファイル・ディスクリプタと新しいファイル・ディスクリプタは
-互いに可換なものとして使うことができる。
-2つのファイル・ディスクリプタは同じファイル記述 (description)
-.RB ( open (2)
-参照) を参照しており、したがってファイルオフセットやファイル状態フラグが
-共有される。例えば、一方のディスクリプタに対して
-.BR lseek (2)
-を使ってファイルオフセットを変更した場合、もう一方のディスクリプタの
-オフセットも変化する。
+これらのシステムコールのいずれかが成功を返した場合には、 古いファイル・ディスクリプタと新しいファイル・ディスクリプタは
+互いに可換なものとして使うことができる。 2つのファイル・ディスクリプタは同じファイル記述 (description) (\fBopen\fP(2)
+参照) を参照しており、したがってファイルオフセットやファイル状態フラグが 共有される。例えば、一方のディスクリプタに対して \fBlseek\fP(2)
+を使ってファイルオフセットを変更した場合、もう一方のディスクリプタの オフセットも変化する。
-.\"O The two descriptors do not share file descriptor flags
-.\"O (the close-on-exec flag).
-.\"O The close-on-exec flag
-.\"O .RB ( FD_CLOEXEC ;
-.\"O see
-.\"O .BR fcntl (2))
-.\"O for the duplicate descriptor is off.
-2つのディスクリプタはファイル・ディスクリプタ・フラグ (close-on-exec flag)
-を共有しない。複製されたディスクリプタの
-close-on-exec flag
-.RB ( fcntl (2)
-参照) は off となる。
+2つのディスクリプタはファイル・ディスクリプタ・フラグ (close\-on\-exec flag) を共有しない。複製されたディスクリプタの
+close\-on\-exec flag (\fBfcntl\fP(2) 参照) は off となる。
-.\"O .BR dup3 ()
-.\"O is the same as
-.\"O .BR dup2 (),
-.\"O except that:
-.BR dup3 ()
-は
-.BR dup2 ()
-と同じだが、以下の点が異なる。
+\fBdup3\fP() は \fBdup2\fP() と同じだが、以下の点が異なる。
.IP * 3
-.\"O The caller can force the close-on-exec flag to be set
-.\"O for the new file descriptor by specifying
-.\"O .BR O_CLOEXEC
-.\"O in
-.\"O .IR flags .
-.\"O See the description of the same flag in
-.\"O .BR open (2)
-.\"O for reasons why this may be useful.
-呼び出し元が、新しいファイル・ディスクリプタに対して
-close-on-exec フラグを強制的に設定することができる。
-これを行うには、
-.I flags
-に
-.B O_CLOEXEC
-を指定する。
-このフラグが役に立つ理由については、
-.BR open (2)
-の
-.B O_CLOEXEC
+呼び出し元が、新しいファイル・ディスクリプタに対して close\-on\-exec フラグを強制的に設定することができる。 これを行うには、
+\fIflags\fP に \fBO_CLOEXEC\fP を指定する。 このフラグが役に立つ理由については、 \fBopen\fP(2) の \fBO_CLOEXEC\fP
フラグの説明を参照のこと。
.IP *
.\" FIXME . To confirm with Al Viro that this was intended, and its rationale
-.\"O If
-.\"O .IR oldfd
-.\"O equals
-.\"O .IR newfd ,
-.\"O then
-.\"O .BR dup3 ()
-.\"O fails with the error
-.\"O .BR EINVAL .
-.I oldfd
-が
-.I newfd
-と同じ場合、
-.BR dup3 ()
-は
-.B EINVAL
-エラーで失敗する。
-.\"O .SH "RETURN VALUE"
+\fIoldfd\fP が \fInewfd\fP と同じ場合、 \fBdup3\fP() は \fBEINVAL\fP エラーで失敗する。
.SH 返り値
-.\"O On success, these system calls
-.\"O return the new descriptor.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-成功すると、これらのシステムコールは新しいディスクリプタを返す。
-エラーの場合、\-1 を返し、
-.I errno
-を適切に設定する。
-.\"O .SH ERRORS
+成功すると、これらのシステムコールは新しいディスクリプタを返す。 エラーの場合、\-1 を返し、 \fIerrno\fP を適切に設定する。
.SH エラー
-.TP
-.\"O .B EBADF
-.\"O .I oldfd
-.\"O isn't an open file descriptor, or
-.\"O .I newfd
-.\"O is out of the allowed range for file descriptors.
-.B EBADF
-.I oldfd
-がオープンされたファイル・ディスクリプタでないか、
-.I newfd
-がファイル・ディスクリプタとして許される範囲から外れている。
-.TP
-.B EBUSY
-.\"O (Linux only) This may be returned by
-.\"O .BR dup2 ()
-.\"O or
-.\"O .BR dup3 ()
-.\"O during a race condition with
-.\"O .BR open (2)
-.\"O and
-.\"O .BR dup ().
-(Linux のみ)
-.BR open (2)
-や
-.BR dup ()
-との競合状態の場合に、
-.BR dup2 ()
-や
-.BR dup3 ()
+.TP
+\fBEBADF\fP
+\fIoldfd\fP がオープンされたファイル・ディスクリプタでないか、 \fInewfd\fP がファイル・ディスクリプタとして許される範囲から外れている。
+.TP
+\fBEBUSY\fP
+(Linux のみ) \fBopen\fP(2) や \fBdup\fP() との競合状態の場合に、 \fBdup2\fP() や \fBdup3\fP()
はこのエラーを返すかもしれない。
-.TP
-.B EINTR
-.\"O The
-.\"O .BR dup2 ()
-.\"O or
-.\"O .BR dup3 ()
-.\"O call was interrupted by a signal; see
-.\"O .BR signal (7).
-.BR dup2 ()
-や
-.BR dup3 ()
-の呼び出しがシグナルにより割り込まれた。
-.BR signal (7)
-参照。
-.TP
-.B EINVAL
-.\"O .RB ( dup3 ())
-.\"O .I flags
-.\"O contain an invalid value.
-.RB ( dup3 ())
-.I flags
-に無効な値が入っている。
+.TP
+\fBEINTR\fP
+\fBdup2\fP() や \fBdup3\fP() の呼び出しがシグナルにより割り込まれた。 \fBsignal\fP(7) 参照。
+.TP
+\fBEINVAL\fP
.\" FIXME . To confirm with Al Viro that this was intended, and its rationale
-.\"O Or,
-.\"O .I oldfd
-.\"O was equal to
-.\"O .IR newfd .
-もしくは、
-.I oldfd
-が
-.I newfd
-と同じであった。
-.TP
-.\"O .B EMFILE
-.\"O The process already has the maximum number of file
-.\"O descriptors open and tried to open a new one.
-.B EMFILE
-プロセスがすでにオープンできる最大数までファイル・ディスクリプタ
-を開いていて、さらに新しいものを開こうとした。
-.\"O .SH VERSIONS
+(\fBdup3\fP()) \fIflags\fP に無効な値が入っている。 もしくは、 \fIoldfd\fP が \fInewfd\fP と同じであった。
+.TP
+\fBEMFILE\fP
+プロセスがすでにオープンできる最大数までファイル・ディスクリプタ を開いていて、さらに新しいものを開こうとした。
.SH バージョン
-.\"O .BR dup3 ()
-.\"O was added to Linux in version 2.6.27;
-.\"O glibc support is available starting with
-.\"O version 2.9.
-.BR dup3 ()
-はバージョン 2.6.27 で Linux に追加された。
-glibc によるサポートはバージョン 2.9 以降で利用できる。
-.\"O .SH "CONFORMING TO"
+\fBdup3\fP() はバージョン 2.6.27 で Linux に追加された。 glibc によるサポートはバージョン 2.9 以降で利用できる。
.SH 準拠
-.BR dup (),
-.BR dup2 ():
-SVr4, 4.3BSD, POSIX.1-2001.
+\fBdup\fP(), \fBdup2\fP(): SVr4, 4.3BSD, POSIX.1\-2001.
-.\"O .BR dup3 ()
-.\"O is Linux-specific.
-.BR dup3 ()
-は Linux 固有である。
-.\"O .\" SVr4 documents additional
-.\"O .\" EINTR and ENOLINK error conditions. POSIX.1 adds EINTR.
-.\"O .\" The EBUSY return is Linux-specific.
-.\" SVr4 には他に EINTR, ENOLINK エラー状態の記述がある。
-.\" POSIX.1 には他に EINTR がある。
-.\" EBUSY が返されるのは Linux 独自のものである。
-.\"O .SH NOTES
+.\" SVr4 documents additional
+.\" EINTR and ENOLINK error conditions. POSIX.1 adds EINTR.
+.\" The EBUSY return is Linux-specific.
+\fBdup3\fP() は Linux 固有である。
.SH 注意
-.\"O The error returned by
-.\"O .BR dup2 ()
-.\"O is different from that returned by
-.\"O .BR fcntl( "..., " F_DUPFD ", ..." )
-.\"O when
-.\"O .I newfd
-.\"O is out of range.
-.\"O On some systems
-.\"O .BR dup2 ()
-.\"O also sometimes returns
-.\"O .B EINVAL
-.\"O like
-.\"O .BR F_DUPFD .
-.I newfd
-が範囲を超えた時に返されるエラーは、
-.BR dup2 ()
-と
-.BR fcntl( "..., " F_DUPFD ", ..." )
-では異っている。
-.BR dup2 ()
-が
-.B F_DUPFD
-と同じように
-.B EINVAL
-を返すシステムもある。
+\fInewfd\fP が範囲を超えた時に返されるエラーは、 \fBdup2\fP() と \fBfcntl(\fP..., \fBF_DUPFD\fP, ...\fB)\fP
+では異っている。 \fBdup2\fP() が \fBF_DUPFD\fP と同じように \fBEINVAL\fP を返すシステムもある。
-.\"O If
-.\"O .I newfd
-.\"O was open, any errors that would have been reported at
-.\"O .BR close 2()
-.\"O time are lost.
-.\"O A careful programmer will not use
-.\"O .BR dup2 ()
-.\"O or
-.\"O .BR dup3 ()
-.\"O without closing
-.\"O .I newfd
-.\"O first.
-.I newfd
-がオープンされていると、
-.BR close (2)
-した時に報告されるはずのエラーが失われてしまう。
-.BR dup2 ()
-や
-.BR dup3 ()
-を使う前に先ず
-.I newfd
-をクローズするようにした方がいいだろう。
-.\"O .SH "SEE ALSO"
+\fInewfd\fP がオープンされていると、 \fBclose\fP(2) した時に報告されるはずのエラーが失われてしまう。 \fBdup2\fP() や
+\fBdup3\fP() を使う前に先ず \fInewfd\fP をクローズするようにした方がいいだろう。
.SH 関連項目
-.BR close (2),
-.BR fcntl (2),
-.BR open (2)
+\fBclose\fP(2), \fBfcntl\fP(2), \fBopen\fP(2)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。