Skip to main content

Module exec

Module exec 

Source
Expand description

execute_command tool.

The ExecContext::token races the subprocess wait in a select!. When the user Ctrl+C’s:

  1. Reducer emits Cmd::CancelScope(turn).
  2. Effect runner cancels the turn’s scope token.
  3. run_command’s cancel branch fires, terminate_tree SIGKILLs the child’s whole process group, the driver is aborted, and ToolOutcome::Cancelled flows back to the reducer. (The child is deliberately NOT kill_on_drop, so a Ctrl+B-detached command survives a clean shutdown — see the spawn site.)

End-to-end latency: microseconds plus whatever it takes SIGKILL to arrive. No polling loop to “forget” to include.

The dangerous-command blocklist is defense-in-depth, not a security boundary: the real boundary is the user’s decision to run Mermaid with shell access. But the known destructive shapes (rm -rf /, fork bombs, dd to device, etc.) are cheap to catch upfront.

Structs§

ExecuteCommandTool
execute_command — spawn a shell, run a command, capture output.