(pid: u32)
| 173 | /// Read the `PPid` (parent PID) from `/proc/<pid>/status`. |
| 174 | #[cfg(target_os = "linux")] |
| 175 | pub fn read_ppid(pid: u32) -> Option<u32> { |
| 176 | let status = std::fs::read_to_string(format!("/proc/{pid}/status")).ok()?; |
| 177 | for line in status.lines() { |
| 178 | if let Some(rest) = line.strip_prefix("PPid:") { |
| 179 | return rest.trim().parse().ok(); |
| 180 | } |
| 181 | } |
| 182 | None |
| 183 | } |
| 184 | |
| 185 | /// Walk the process tree upward from `pid`, collecting the binary path of each ancestor. |
| 186 | /// |