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

Function check_pid_fds

crates/openshell-supervisor-network/src/procfs.rs:407–420  ·  view source on GitHub ↗
(pid: u32, target: &str)

Source from the content-addressed store, hash-verified

405/// Check if a PID has an fd pointing to the given socket target string.
406#[cfg(target_os = "linux")]
407fn 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///

Callers 1

find_socket_inode_ownersFunction · 0.70

Calls 1

pathMethod · 0.80

Tested by

no test coverage detected