#, fuzzy msgid "" msgstr "" "Project-Id-Version: man-pages-l10n VERSION\n" "POT-Creation-Date: 2014-07-17 17:53+0900\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: man-pages/man2/dup.2:37 #, no-wrap msgid "DUP" msgstr "" #. type: TH #: man-pages/man2/dup.2:37 #, no-wrap msgid "2014-07-08" msgstr "" #. type: TH #: man-pages/man2/dup.2:37 #, no-wrap msgid "Linux" msgstr "" #. type: TH #: man-pages/man2/dup.2:37 #, no-wrap msgid "Linux Programmer's Manual" msgstr "" #. type: SH #: man-pages/man2/dup.2:38 #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:40 msgid "dup, dup2, dup3 - duplicate a file descriptor" msgstr "" #. type: SH #: man-pages/man2/dup.2:40 #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:43 #, no-wrap msgid "B<#include Eunistd.hE>\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:46 #, no-wrap msgid "" "BIB<);>\n" "BIB<, int >IB<);>\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:50 #, no-wrap msgid "" "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n" "B<#include Efcntl.hE> /* Obtain O_* constant " "definitions */\n" "B<#include Eunistd.hE>\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:52 #, no-wrap msgid "BIB<, int >IB<, int >IB<);>\n" msgstr "" #. type: SH #: man-pages/man2/dup.2:53 #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:59 msgid "" "The B() system call creates a copy of the file descriptor I, " "using the lowest-numbered unused descriptor for the new descriptor." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:68 msgid "" "After a successful return, the old and new file descriptors may be used " "interchangeably. They refer to the same open file description (see " "B(2)) and thus share file offset and file status flags; for example, " "if the file offset is modified by using B(2) on one of the " "descriptors, the offset is also changed for the other." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:77 msgid "" "The two descriptors do not share file descriptor flags (the close-on-exec " "flag). The close-on-exec flag (B; see B(2)) for the " "duplicate descriptor is off." msgstr "" #. type: SS #: man-pages/man2/dup.2:77 #, no-wrap msgid "dup2()" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:88 msgid "" "The B() system call performs the same task as B(), but instead " "of using the lowest-numbered unused file descriptor, it uses the descriptor " "number specified in I. If the descriptor I was previously " "open, it is silently closed before being reused." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:104 msgid "" "The steps of closing and reusing the file descriptor I are performed " "I. This is important, because trying to implement equivalent " "functionality using B(2) and B() would be subject to race " "conditions, whereby I might be reused between the two steps. Such " "reuse could happen because the main program is interrupted by a signal " "handler that allocates a file descriptor, or because a parallel thread " "allocates a file descriptor." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:106 msgid "Note the following points:" msgstr "" #. type: IP #: man-pages/man2/dup.2:106 man-pages/man2/dup.2:112 man-pages/man2/dup.2:129 man-pages/man2/dup.2:138 #, no-wrap msgid "*" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:112 msgid "" "If I is not a valid file descriptor, then the call fails, and " "I is not closed." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:124 msgid "" "If I is a valid file descriptor, and I has the same value as " "I, then B() does nothing, and returns I." msgstr "" #. type: SS #: man-pages/man2/dup.2:124 #, no-wrap msgid "dup3()" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:129 msgid "B() is the same as B(), except that:" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:138 msgid "" "The caller can force the close-on-exec flag to be set for the new file " "descriptor by specifying B in I. See the description of " "the same flag in B(2) for reasons why this may be useful." msgstr "" #. FIXME . To confirm with Al Viro that this was intended, and its rationale #. type: Plain text #: man-pages/man2/dup.2:148 msgid "" "If I equals I, then B() fails with the error B." msgstr "" #. type: SH #: man-pages/man2/dup.2:148 #, no-wrap msgid "RETURN VALUE" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:154 msgid "" "On success, these system calls return the new descriptor. On error, -1 is " "returned, and I is set appropriately." msgstr "" #. type: SH #: man-pages/man2/dup.2:154 #, no-wrap msgid "ERRORS" msgstr "" #. type: TP #: man-pages/man2/dup.2:155 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:161 msgid "" "I isn't an open file descriptor, or I is out of the allowed " "range for file descriptors." msgstr "" #. type: TP #: man-pages/man2/dup.2:161 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:171 msgid "" "(Linux only) This may be returned by B() or B() during a race " "condition with B(2) and B()." msgstr "" #. type: TP #: man-pages/man2/dup.2:171 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:179 msgid "" "The B() or B() call was interrupted by a signal; see " "B(7)." msgstr "" #. type: TP #: man-pages/man2/dup.2:179 #, no-wrap msgid "B" msgstr "" #. FIXME . To confirm with Al Viro that this was intended, and its rationale #. type: Plain text #: man-pages/man2/dup.2:189 msgid "" "(B()) I contain an invalid value. Or, I was equal to " "I." msgstr "" #. type: TP #: man-pages/man2/dup.2:189 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:193 msgid "" "The process already has the maximum number of file descriptors open and " "tried to open a new one." msgstr "" #. type: SH #: man-pages/man2/dup.2:193 #, no-wrap msgid "VERSIONS" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:198 msgid "" "B() was added to Linux in version 2.6.27; glibc support is available " "starting with version 2.9." msgstr "" #. type: SH #: man-pages/man2/dup.2:198 #, no-wrap msgid "CONFORMING TO" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:202 msgid "B(), B(): SVr4, 4.3BSD, POSIX.1-2001." msgstr "" #. SVr4 documents additional #. EINTR and ENOLINK error conditions. POSIX.1 adds EINTR. #. The EBUSY return is Linux-specific. #. type: Plain text #: man-pages/man2/dup.2:208 msgid "B() is Linux-specific." msgstr "" #. type: SH #: man-pages/man2/dup.2:208 #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:222 msgid "" "The error returned by B() is different from that returned by " "B..., B, ...B<)> when I is out of range. On some " "systems, B() also sometimes returns B like B." msgstr "" #. type: Plain text #: man-pages/man2/dup.2:238 msgid "" "If I was open, any errors that would have been reported at " "B(2) time are lost. If this is of concern, then\\(emunless the " "program is single-threaded and does not allocate file descriptors in signal " "handlers\\(emthe correct approach is I to close I before calling " "B(), because of the race condition described above. Instead, code " "something like the following could be used:" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:243 #, no-wrap msgid "" " /* Obtain a duplicate of 'newfd' that can subsequently\n" " be used to check for close() errors; an EBADF error\n" " means that 'newfd' was not open. */\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:248 #, no-wrap msgid "" " tmpfd = dup(newfd);\n" " if (tmpfd == -1 && errno != EBADF) {\n" " /* Handle unexpected dup() error */\n" " }\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:250 #, no-wrap msgid " /* Atomically duplicate 'oldfd' on 'newfd' */\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:254 #, no-wrap msgid "" " if (dup2(oldfd, newfd) == -1) {\n" " /* Handle dup2() error */\n" " }\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:257 #, no-wrap msgid "" " /* Now check for close() errors on the file originally\n" " referred to by 'newfd' */\n" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:263 #, no-wrap msgid "" " if (tmpfd != -1) {\n" " if (close(tmpfd) == -1) {\n" " /* Handle errors from close */\n" " }\n" " }\n" msgstr "" #. type: SH #: man-pages/man2/dup.2:264 #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:268 msgid "B(2), B(2), B(2)" msgstr "" #. type: SH #: man-pages/man2/dup.2:268 #, no-wrap msgid "COLOPHON" msgstr "" #. type: Plain text #: man-pages/man2/dup.2:276 msgid "" "This page is part of release 3.70 of the Linux I project. A " "description of the project, information about reporting bugs, and the latest " "version of this page, can be found at \\%http://www.kernel.org/doc/man-pages/" "." msgstr ""