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

Function read_forward_pid

crates/openshell-core/src/forward.rs:77–89  ·  view source on GitHub ↗

Read the PID from a forward PID file. Returns `None` if the file does not exist or cannot be parsed.

(name: &str, port: u16)

Source from the content-addressed store, hash-verified

75/// Read the PID from a forward PID file. Returns `None` if the file does not
76/// exist or cannot be parsed.
77pub fn read_forward_pid(name: &str, port: u16) -> Option<ForwardPidRecord> {
78 let path = forward_pid_path(name, port).ok()?;
79 let contents = std::fs::read_to_string(path).ok()?;
80 let mut parts = contents.split('\t');
81 let pid = parts.next()?.trim().parse().ok()?;
82 let sandbox_id = parts.next().map(str::to_string);
83 let bind_addr = parts.next().map(|s| s.trim().to_string());
84 Some(ForwardPidRecord {
85 pid,
86 sandbox_id,
87 bind_addr,
88 })
89}
90
91/// Check whether a process is alive.
92pub fn pid_is_alive(pid: u32) -> bool {

Calls 3

forward_pid_pathFunction · 0.85
parseMethod · 0.45
nextMethod · 0.45