Returns a file descriptor that refers to the same open file as fildes.
#include <unistd.h> int dup ( int fildes);
(IN) Specifies the file descriptor that is to be duplicated.
If successful, returns a nonnegative integer that is the duplicated file descriptor. Otherwise, returns -1 and sets errno to one of the following values:
The dup function duplicates a file descriptor by returning a file descriptor that refers to the same open file as the fildes parameter. Because both handles reference the same file, either handle can be used for operations on the file.