pub struct PidFd { /* private fields */ }linux_pidfd)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 into_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
.into_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.
Implementations§
Source§impl PidFd
impl PidFd
Sourcepub fn kill(&self) -> Result<(), Error>
🔬This is a nightly-only experimental API. (linux_pidfd)
pub fn kill(&self) -> Result<(), Error>
linux_pidfd)Forces the child process to exit.
Unlike Child::kill it is possible to attempt to kill
reaped children since PidFd does not suffer from pid recycling
races. But doing so will return an Error.
Sourcepub fn wait(&self) -> Result<ExitStatus, Error>
🔬This is a nightly-only experimental API. (linux_pidfd)
pub fn wait(&self) -> Result<ExitStatus, Error>
linux_pidfd)Waits for the child to exit completely, returning the status that it exited with.
Unlike Child::wait it does not ensure that the stdin handle is closed.
Additionally it will not return an ExitStatus if the child
has already been reaped. Instead an error will be returned.
Sourcepub fn try_wait(&self) -> Result<Option<ExitStatus>, Error>
🔬This is a nightly-only experimental API. (linux_pidfd)
pub fn try_wait(&self) -> Result<Option<ExitStatus>, Error>
linux_pidfd)Attempts to collect the exit status of the child if it has already exited.
Unlike Child::try_wait this method will return an Error
if the child has already been reaped.
Trait Implementations§
Source§impl AsFd for PidFd
impl AsFd for PidFd
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
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
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more