Check whether a process is alive.
(pid: u32)
| 90 | |
| 91 | /// Check whether a process is alive. |
| 92 | pub fn pid_is_alive(pid: u32) -> bool { |
| 93 | // `kill -0 <pid>` checks if we can signal the process without actually |
| 94 | // sending a signal. |
| 95 | Command::new("kill") |
| 96 | .arg("-0") |
| 97 | .arg(pid.to_string()) |
| 98 | .stdout(std::process::Stdio::null()) |
| 99 | .stderr(std::process::Stdio::null()) |
| 100 | .status() |
| 101 | .is_ok_and(|s| s.success()) |
| 102 | } |
| 103 | |
| 104 | /// Validate that a PID belongs to the expected `OpenShell` SSH forward. |
| 105 | pub fn pid_matches_openshell_ssh_forward(pid: u32, port: u16, sandbox_id: Option<&str>) -> bool { |
no test coverage detected