dup(3)
DESCRIPTION
Creates the lowest-numbered available descriptor referring to the same open file description as fd.
SYNOPSIS
#include <unistd.h> int dup(int fd);
RETURN VALUE
- Returns the new descriptor, or -1 and sets errno.
ERRORS
-EBADF- Fd does not refer to an open descriptor.
-EMFILE- The process descriptor table has no free entry.
NOTES
The duplicate shares the underlying file position and open status with fd.