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

Function track_background_forward_or_cleanup

crates/openshell-cli/src/ssh.rs:498–512  ·  view source on GitHub ↗

Track a verified background forward, cleaning it up if PID-file persistence fails.

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

Source from the content-addressed store, hash-verified

496
497/// Track a verified background forward, cleaning it up if PID-file persistence fails.
498fn track_background_forward_or_cleanup(
499 name: &str,
500 port: u16,
501 pid: u32,
502 sandbox_id: &str,
503 bind_addr: &str,
504 cleanup: impl FnOnce(),
505) -> Result<()> {
506 if let Err(err) = write_forward_pid(name, port, pid, sandbox_id, bind_addr) {
507 cleanup();
508 return Err(err)
509 .wrap_err("local forward listener was reachable but tracking the SSH process failed");
510 }
511 Ok(())
512}
513
514fn foreground_forward_started_message(name: &str, spec: &ForwardSpec) -> String {
515 format!(

Calls 1

write_forward_pidFunction · 0.85

Tested by

no test coverage detected