📄 syscalls_11.html
字号:
<!-- This HTML file has been created by texi2html 1.29
from syscalls.texi on 4 June 1994 -->
<TITLE>Syscall specifications of Linux - dup</TITLE>
<P>Go to the <A HREF="syscalls_10.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_10.html">previous</A>, <A HREF="syscalls_12.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_12.html">next</A> section.<P>
<H2><A NAME="SEC11" HREF="syscalls_toc.html#SEC11" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC11">dup and dup2</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int dup(int <VAR>oldfd</VAR>);</CODE>
<P>
<CODE>int dup2(int <VAR>oldfd</VAR>, int <VAR>newfd</VAR>);</CODE>
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>oldfd</VAR>: [in] the file descriptor to copy.
<P>
<VAR>newfd</VAR>: [in] the file descriptor to copy to.
<P>
<H3>DESCRIPTION</H3>
<P>
<CODE>dup</CODE> duplicates a file descriptor to the lowest unused file
descriptor available. <CODE>dup2</CODE> duplicates a file descriptor to
another specified file descriptor. If the destination file descriptor is
already used, it is closed. The two descriptors share all (ie. file
locks, position, etc.) but the close-on-exec flag.
<P>
<H3>RETURN VALUE</H3>
<P>
The call returns the new descriptor on success. It returns -1 on error
and sets <CODE>errno</CODE> to one of the following values: <CODE>EBADF</CODE> or
<CODE>EMFILE</CODE>.
<P>
<STRONG>NOTE</STRONG>: <CODE>EINVAL</CODE> might well be added to the set of possible
errors in the future. (Take a look in the kernel source.)
<P>
<P>Go to the <A HREF="syscalls_10.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_10.html">previous</A>, <A HREF="syscalls_12.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_12.html">next</A> section.<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -