Skip to main content

run_command

Function run_command 

Source
pub fn run_command(
    args: &ShellArgs,
    root: &Path,
    cancel: &CancelToken,
) -> Result<ProcessResult, String>
Expand description

Run a shell command with streaming output capture, timeout, and cancellation.

This is the synchronous execution path used for one-shot commands. The blocking read runs on the calling thread; callers that need non-blocking behavior should run this on a worker thread and drain the returned ProcessResult through the agent event channel.

The process is killed if:

  • the timeout elapses, or
  • the CancelToken is signalled.

stdout/stderr are read on dedicated threads so that a process producing no output (e.g. sleep 30) can still be killed on timeout/cancellation. The captured output is capped at MAX_OUTPUT_BYTES bytes and MAX_OUTPUT_LINES lines. Lines longer than MAX_LINE_LEN chars are truncated with ....