Function nix::unistd::dup2

source ·
pub fn dup2<Fd: AsFd>(oldfd: Fd, newfd: &mut OwnedFd) -> Result<()>
Expand description

Create a copy of oldfd using newfd.

This function behaves similar to dup() except that it will try to use the specified fd newfd instead of allocating a new one. See the man pages for more detail on the exact behavior of this function.

This function does not allow you to duplicate oldfd with any file descriptor you want, to do that, use dup2_raw().

§Stdin/Stdout/Stderr redirection

To duplicate a fd with Stdin/Stdout/Stderr, see:

§Reference

dup(2)