dup2(2) DG/UX 4.30 dup2(2)
NAME
dup2 - Duplicate an open file descriptor onto a specific
descriptor.
SYNOPSIS
int dup2 (old_fildes, new_fildes)
int old_fildes;
int new_fildes;
PARAMETERS
old_fildes A valid, active file descriptor.
new_fildes Another file descriptor.
DESCRIPTION
Dup2 combines the functionality of the dup and close
operations.
If <old_fildes> is an active, valid descriptor and
<new_fildes> is a valid descriptor (active or not),
<new_fildes> is made a duplicate of <old_fildes>. If
<old_fildes> and <new_fildes> already refer to the same
object pointer, no changes occur. In all other situations
in which <new_fildes> is active, it is closed before being
made a duplicate of <old_fildes>. The close-on-exec flag is
set so the descriptor remains open across exec(2)
operations. For a further discussion of the semantics of
duplication and closing, see the dup and close operations
respectively.
If <old_fildes> equals <new_fildes>, no changes occur.
However, an error will be returned if <old_fildes> is not an
active, valid descriptor.
ACCESS CONTROL
None.
RETURN VALUE
<new_fildes> The value of the new file descriptor given by
<new_fildes>.
-1 An error occurred. Errno is set to indicate
the error.
EXCEPTIONS
Errno may be set to one of the following error codes:
EBADF <Old_fildes> is not a valid, active
descriptor.
Licensed material--property of copyright holder(s) Page 1
dup2(2) DG/UX 4.30 dup2(2)
EBADF <New_fildes> is not a valid descriptor.
SEE ALSO
The related manual sections: accept(2), close(2), creat(2),
dup(2), exec(2), fcntl(2), getdtablesize(2), open(2),
pipe(2), socket(2), socketpair(2).
STANDARDS
When using m88kbcs as the Software Development Environment
target, the dup2 function will be emulated using BCS system
calls. Since this is an emulation requiring several BCS
system calls, a slight performance degradation may be
noticed in comparison to using dup2 in /lib/libc.a.
Licensed material--property of copyright holder(s) Page 2