Function DUP

Syntax

dup file-descriptor => copy, error

Arguments and values

file-descriptor -- A non-negative fixnum.

copy -- A non-negative fixnum.

error -- A fixnum.

Description

This function creates and a copy of file-descriptor. The returned file descriptor is the lowest-numbered unused file descriptor.

After a successful return from this system call, the old and new file descriptors may be used interchangeably. They refer to the same open file description (see open) and thus share file offset and file status flags; for example, if the file offset is modified by using lseek on one of the descriptors, the offset is also changed for the other.

The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl) for the duplicate descriptor is off.

Errors

+ebadf+ file-descriptor is not an open file descriptor.