//! Linux `(pid, ppid)` snapshot: iterate the numeric directories under `/proc`
//! and read field 4 of each `stat` via the comm-safe `parse_ppid`.
usecrate::identity::stat_parse::parse_ppid;usecrate::identity::RawPid;pub(crate)fnprocess_parents()->Vec<(RawPid, RawPid)>{letmut out =Vec::new();letOk(entries)=std::fs::read_dir("/proc")else{return out;};for entry in entries.flatten(){// /proc/<pid> directories are named by their decimal pid; skip the rest.
letSome(pid)= entry.file_name().to_str().and_then(|n|n.parse::<RawPid>().ok())else{continue;};// The process may exit between read_dir and read; that's just absence.
letOk(stat)=std::fs::read(format!("/proc/{pid}/stat"))else{continue;};ifletSome(ppid)=parse_ppid(&stat){
out.push((pid, ppid));}}
out
}