Skip to main content

wait_pid

Function wait_pid 

Source
pub fn wait_pid(pid: u32, timeout: Duration) -> SysprimsResult<WaitPidResult>
Expand description

Wait for a PID to exit, up to the provided timeout.

Returns:

  • Ok with timed_out=true if the process did not exit in time.
  • Ok with exited=true if the process was observed to have exited.
  • Err(NotFound) if the PID does not exist at the time of the first check.
  • Err(PermissionDenied) if the platform forbids even querying liveness.

ยงExamples

use std::time::Duration;

// Replaces: while kill -0 <pid>; do sleep ...; done
let res = sysprims_proc::wait_pid(std::process::id(), Duration::from_millis(1)).unwrap();
println!("timed_out: {}", res.timed_out);