Function dup3

fn dup3<Fd: std::os::fd::AsFd>(oldfd: Fd, newfd: &mut OwnedFd, flags: OFlag) -> Result<()>

Create a new copy of the specified file descriptor using the specified fd and flags.

This function behaves similar to [dup2()] but allows flags to be specified for the new file descriptor. Currently, the only flag that is allowed is OFlag::O_CLOEXEC, setting other flags will return EINVAL. Also, if oldfd and newfd have the same fd value, EINVAL will also be returned.

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

References