(pid: u32, target: &str)
| 405 | /// Check if a PID has an fd pointing to the given socket target string. |
| 406 | #[cfg(target_os = "linux")] |
| 407 | fn check_pid_fds(pid: u32, target: &str) -> bool { |
| 408 | let fd_dir = format!("/proc/{pid}/fd"); |
| 409 | let Some(fds) = std::fs::read_dir(&fd_dir).ok() else { |
| 410 | return false; |
| 411 | }; |
| 412 | for fd_entry in fds.flatten() { |
| 413 | if let Ok(link) = std::fs::read_link(fd_entry.path()) |
| 414 | && link.to_string_lossy() == target |
| 415 | { |
| 416 | return true; |
| 417 | } |
| 418 | } |
| 419 | false |
| 420 | } |
| 421 | |
| 422 | /// Collect all descendant PIDs of a root process using `/proc/<pid>/task/<tid>/children`. |
| 423 | /// |
no test coverage detected