pidfd_getfd
This crate provides a direct binding to the pidfd_getfd syscall along with
a slightly more convenient wrapper, get_file_from_pidfd. This also contains
an extension trait for pidfd::PidFd and std's PidFd (currently only
available on nightly rustc) which provides access to get_file_from_pidfd via
PidFdExt::get_file().
Note that pidfds are currently only supported on Linux 5.6 or later, thus this crate
will only work on Linux. If any other platform gains support for pidfds, please
let me know through an issue or pull request!
Please note that this crate has not been thoroughly tested. Viewer discretion is advised.
Example
use ;
use ;
let pidfd: RawFd = /* ... */;
let target_fd: RawFd = /* ... */;
let mut file = get_file_from_pidfd?;
let mut buf = Vecnew;
file.read_to_end?;
println!;
Ok
Using pidfd:
use PidFd;
use ;
use Command;
let child = new.spawn.expect;
let pidfd = from_std_checked?;
let file_from_child = pidfd.get_file?;
Using nightly rustc:
use ;
use ;
let child = new
.create_pidfd
.spawn
.expect;
let file_from_child = child.pidfd?.get_file?;