◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back► ──────────────────────────────────────────────────────────────────────────── The dup and dup2 functions cause a second file handle to be associated with a currently open file. Operations on the file can be carried out using either file handle. The type of access allowed for the file is unaffected by the creation of a new handle. The dup function returns the next available file handle for the given file. The dup2 function forces <handle2> to refer to the same file as <handle1>. If <handle2> is associated with an open file at the time of the call, that file is closed. Return Value The dup function returns a new file handle. The dup2 function returns 0 to indicate success. Both functions return -1 if an error occurs and set errno to either EBADF or EMFILE. -♦-