waitpidx
waitpidx provides Linux process waiting by PID (not limited to child processes).
It uses pidfd_open(2) + poll(2) under the hood and supports both:
- synchronous waiting
- asynchronous waiting with Tokio
Requirements
- Linux only
- Kernel
>= 5.3(pidfd_open) - Rust stable (Edition 2024)
Install
[]
= "0.0.1"
Disable default async feature when you only need sync API:
[]
= { = "0.0.1", = false }
Quick start
Sync API
use ;
Async API (Tokio)
use Command;
async
Public API
waitpid(pid, timeout)- Wait for process exit with optional timeout.
- Returns
TimedOutwhen timeout expires.
waitpid_async(pid)- Async wait for process exit.
pidfd::PidFd/pidfd::AsyncPidFd- Low-level wrappers if you need reusable wait handles.
process_exists(pid)- Cheap existence check based on signal 0 semantics.
Error behavior
Common std::io::ErrorKind values:
InvalidInput: invalid PID (for example0), or invalid timeout conversionTimedOut: timeout reached in sync waitNotFound/PermissionDenied/ others: forwarded from OS (pidfd_open,poll, etc.)
Features
async(default): enables Tokio-based async API
Examples
Run included examples:
License
Apache-2.0