Function nc::dup2[][src]

pub fn dup2(oldfd: i32, newfd: i32) -> Result<(), Errno>
Expand description

Create a copy of the file descriptor oldfd, using the speficified file descriptor newfd.

let path = "/tmp/nc-dup2-file";
let fd = nc::creat(path, 0o644);
assert!(fd.is_ok());
let fd = fd.unwrap();
let newfd = 8;
assert!(nc::dup2(fd, newfd).is_ok());
assert!(nc::close(fd).is_ok());
assert!(nc::close(newfd).is_ok());
assert!(nc::unlink(path).is_ok());