pub fn dup<Fd: AsFd>(oldfd: Fd) -> Result<OwnedFd>
Expand description
Create a copy of the specified file descriptor.
The new file descriptor will have a new index but refer to the same resource as the old file descriptor and the old and new file descriptors may be used interchangeably. The new and old file descriptor share the same underlying resource, offset, and file status flags. The actual index used for the file descriptor will be the lowest fd index that is available.
The two file descriptors do not share file descriptor flags (e.g. OFlag::FD_CLOEXEC
).
§Reference
§See also
dup2()
dup2_raw()
dup3()
dup3_raw()