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

Function write_forward_pid

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

Write a PID file for a background forward. File format: ` \t \t `

(
    name: &str,
    port: u16,
    pid: u32,
    sandbox_id: &str,
    bind_addr: &str,
)

Source from the content-addressed store, hash-verified

30///
31/// File format: `<pid>\t<sandbox_id>\t<bind_addr>`
32pub fn write_forward_pid(
33 name: &str,
34 port: u16,
35 pid: u32,
36 sandbox_id: &str,
37 bind_addr: &str,
38) -> Result<()> {
39 let dir = forward_pid_dir()?;
40 create_dir_restricted(&dir)?;
41 let path = forward_pid_path(name, port)?;
42 std::fs::write(&path, format!("{pid}\t{sandbox_id}\t{bind_addr}"))
43 .into_diagnostic()
44 .wrap_err("failed to write forward PID file")?;
45 Ok(())
46}
47
48/// Find the PID of a backgrounded SSH forward by searching for the matching
49/// SSH process. Falls back to `pgrep` since SSH `-f` forks a new process

Callers 2

start_port_forwardsFunction · 0.85

Calls 3

forward_pid_dirFunction · 0.85
create_dir_restrictedFunction · 0.85
forward_pid_pathFunction · 0.85

Tested by

no test coverage detected