Function nc::dup [−][src]
Expand description
Create a copy of the file descriptor oldfd
, using the lowest available
file descriptor.
let path = "/tmp/nc-dup-file";
let fd = nc::openat(nc::AT_FDCWD, path, nc::O_CREAT | nc::O_WRONLY | nc::O_TRUNC, 0o644);
assert!(fd.is_ok());
let fd = fd.unwrap();
let fd_dup = nc::dup(fd);
assert!(fd_dup.is_ok());
let fd_dup = fd_dup.unwrap();
assert!(nc::close(fd).is_ok());
assert!(nc::close(fd_dup).is_ok());
assert!(nc::unlinkat(nc::AT_FDCWD, path, 0).is_ok());