Function rustix::io::dup2
pub fn dup2<Fd: AsFd>(fd: &Fd, new: &OwnedFd) -> io::Result<()>
The portability is definied by:
#[cfg(not(target_os = "wasi"))]
Documentation
dup2(fd, new)
—Creates a new OwnedFd
instance that shares the
same underlying file description as the existing OwnedFd
instance,
closing new
and reusing its file descriptor.
Note that this function does not set the O_CLOEXEC
flag. To do a dup2
that does set O_CLOEXEC
, use dup2_with
with DupFlags::CLOEXEC
on
platforms which support it.