pub struct PidFd {
inner: FileDesc,
}
๐ฌThis is a nightly-only experimental API. (
linux_pidfd
#82971)Available on Linux only.
Expand description
This type represents a file descriptor that refers to a process.
A PidFd
can be obtained by setting the corresponding option on Command
with create_pidfd
. Subsequently, the created pidfd can be retrieved
from the Child
by calling pidfd
or take_pidfd
.
Example:
#![feature(linux_pidfd)]
use std::os::linux::process::{CommandExt, ChildExt};
use std::process::Command;
let mut child = Command::new("echo")
.create_pidfd(true)
.spawn()
.expect("Failed to spawn child");
let pidfd = child
.take_pidfd()
.expect("Failed to retrieve pidfd");
// The file descriptor will be closed when `pidfd` is dropped.
Refer to the man page of pidfd_open(2)
for further details.
Fieldsยง
ยงinner: FileDesc
๐ฌThis is a nightly-only experimental API. (
linux_pidfd
#82971)Trait Implementationsยง
sourceยงimpl AsFd for PidFd
impl AsFd for PidFd
sourceยงfn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more
Auto Trait Implementationsยง
impl Freeze for PidFd
impl RefUnwindSafe for PidFd
impl Send for PidFd
impl Sync for PidFd
impl Unpin for PidFd
impl UnwindSafe for PidFd
Blanket Implementationsยง
sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more