Function dup

Top 

Declaration:

int dup(long handle);

Description

Duplicates a file handle.

dup creates a new file handle that has the following common features with the original file handle:

Same open file or device

Same file pointer (that is, changing the file pointer of one changes the other)

Same access mode (read, write, read/write))

handlecreatopen, dup, or dup2.

Returned value

Upon successful completion, dup returns the new file handle, a nonnegative integer; otherwise, dup returns -1. In the event of error, the errno global variable is set to one of the following values:

  EBADF        Bad file number
  EMFILE       Too many open files