<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
.style2 {font-size: 14px}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">sys_dup <span class="style2">[fs/fcntl.c] </span></span></td>
</tr>
<tr>
<td><p style="margin-left:22px;margin-top:0px"><br />
Duplicates a file descriptor.
After a successful return the old and new file descriptors may be used interchangeably. They refer to the same open file description (see <a href="005.html">sys_open</a>) and thus share file offset and file status flags; for example, if the file offset is modified by using <a href="019.html">sys_lseek</a> on one of the descriptors, the offset is also changed for the other. </p>
<p style="margin-left:10px"><strong>Arguments</strong></p>
<table width="100%" border="0" style="margin-left:20px; margin-right:20px">
<tr>
<td width="6%" valign="top"><em>eax</em></td>
<td width="94%">41</td>
</tr>
<tr>
<td valign="top"><em>ebx</em></td>
<td>File descriptor to duplicate. </td>
</tr>
</table>
<p style="margin-left:10px" ><strong>Return values</strong></p>
<p style="margin-left:22px;margin-right:10px" >If the system call succeeds the return value is the new file descriptor. <br />
If the system call fails the return value is one of the following <em>errno</em> values:</p>
<table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="10%"><code>-EBADF</code></td>
<td width="90%"><em>ebx </em>isn't an open file descriptor.</td>
</tr>
<tr>
<td valign="top"><code>-EMFILE </code></td>
<td>The process already has the maximum number of file descriptors open and tried to open a new one.</td>
</tr>
</table></td>
</tr>
</table>
<p style="margin-left:10px"><strong>Remarks</strong></p>
<p style="margin-left:22px">The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see <a href="055.html">sys_fcntl</a>) for the duplicate descriptor is off. </p>
<p style="margin-left:10px"><strong>Compatibility</strong></p>
<p style="margin-left:22px">n/a</p></td>
</tr>
</table></body></html>