MCPcopy Create free account
hub / github.com/cortexkit/magic-context / run_bounded_binary

Function run_bounded_binary

packages/dashboard/src-tauri/src/commands.rs:798–810  ·  view source on GitHub ↗

Run a binary with args, bounded by [`PROBE_TIMEOUT`]. `kill_on_drop` reaps the child when the future is dropped on timeout so orphans do not accumulate.

(program: &str, args: &[&str])

Source from the content-addressed store, hash-verified

796/// Run a binary with args, bounded by [`PROBE_TIMEOUT`]. `kill_on_drop` reaps
797/// the child when the future is dropped on timeout so orphans do not accumulate.
798async fn run_bounded_binary(program: &str, args: &[&str]) -> Option<String> {
799 let fut = tokio::process::Command::new(program)
800 .args(args)
801 .no_window()
802 .kill_on_drop(true)
803 .output();
804 match tokio::time::timeout(PROBE_TIMEOUT, fut).await {
805 Ok(Ok(output)) if output.status.success() => {
806 Some(String::from_utf8_lossy(&output.stdout).to_string())
807 }
808 _ => None,
809 }
810}
811
812/// Run `command` through the user's login shell and return its stdout on
813/// success. GUI apps don't inherit the shell PATH, and version managers

Calls 2

no_windowMethod · 0.80
successMethod · 0.65

Tested by

no test coverage detected