[−][src]Crate filedesc
This crate exposes a single type: FileDesc
,
which acts as a thin wrapper around open file descriptors.
The wrapped file descriptor is closed when the wrapper is dropped,
unless FileDesc::into_raw_fd()
was called.
A raw file descriptor can be wrapper directly using FileDesc::from_raw_fd()
,
or it can be duplicated and then wrapped using FileDesc::duplicate_raw_fd()
.
It is also possible to duplicate an already-wrapper file descriptor using FileDesc::duplicate()
.
If the platform supports it, all duplicated file descriptors are created with the close-on-exec
flag set atomically,
Example
use filedesc::FileDesc; let fd = unsafe { FileDesc::from_raw_fd(raw_fd) }; let duplicated = fd.duplicate()?; assert_eq!(duplicated.get_close_on_exec()?, true); duplicated.set_close_on_exec(false)?; assert_eq!(duplicated.get_close_on_exec()?, false);
Structs
FileDesc | Thin wrapper around an open file descriptor. |
Functions
check_ret | Wrap the return value of a libc function in an |