Expand description
Wait for Linux processes by PID, even if they are not child processes.
This crate uses pidfd_open(2) and exposes both synchronous and asynchronous
waiting APIs.
§Platform
- Linux only
- Kernel 5.3+ (
pidfd_open)
§Features
async(default): enables Tokio-based async APIs
§Examples
Synchronous wait with timeout:
use std::{
process::Command,
time::Duration,
};
let mut child = Command::new("sleep").arg("0.1").spawn().unwrap();
waitpidx::waitpid(child.id(), Some(Duration::from_secs(3))).unwrap();
child.wait().unwrap();Asynchronous wait (requires async feature):
use std::process::Command;
let mut child = Command::new("sleep").arg("0.1").spawn().unwrap();
waitpidx::waitpid_async(child.id()).await.unwrap();
child.wait().unwrap();Modules§
- pidfd
- pidfd-based wait primitives.
Structs§
- Pid
pid_t—A non-zero Unix process ID.
Functions§
- process_
exists - Return whether a process currently exists.
- waitpid
- Wait for a process to exit.
- waitpid_
async - Wait asynchronously for a process to exit.