MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / read_ppid

Function read_ppid

crates/openshell-supervisor-network/src/procfs.rs:175–183  ·  view source on GitHub ↗
(pid: u32)

Source from the content-addressed store, hash-verified

173/// Read the `PPid` (parent PID) from `/proc/<pid>/status`.
174#[cfg(target_os = "linux")]
175pub 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///

Calls 1

parseMethod · 0.45

Tested by 1