COHERENT manpages

This page displays the COHERENT manpage for dup2() [Duplicate a file descriptor].

List of available manpages
Index


dup2() -- General Function (libc)

Duplicate a file descriptor
#include <unistd.h>
int dup2(fd, newfd) int fd, newfd;

dup2() duplicates  the file descriptor fd. Unlike  its cousin dup(), dup2()
allows you to  specify a new file descriptor newfd,  rather than having the
system select one.   If newfd is already open, the  system closes it before
assigning it to the new file.  dup2() returns the duplicate descriptor.

See Also

dup(),
libc,
stdio.h,
unistd.h
POSIX Standard, §6.2.1

Diagnostics

dup2() returns a number less than  zero when an error occurs, such as a bad
file descriptor or no file descriptor available.