Skip to main content

Module subprocess

Module subprocess 

Source
Expand description

Shared subprocess wrapper for M2/M3 tools.

Every M2 tool spawns apr <subcommand> [...args] --json and passes stdout through to the MCP client verbatim. Non-zero exit maps to isError: true with stderr attached. This module centralizes that pattern so each tool is a thin definition + a list of CLI args.

M3 (FALSIFY-MCP-006) adds run_apr_cancellable, which polls a std::sync::mpsc::Receiver between try_wait checks and escalates to SIGTERM → (grace window) → SIGKILL on the spawned subprocess when a cancellation is signalled. The non-cancellable run_apr is kept as a thin wrapper for tools that don’t support cancellation yet.

Constants§

CANCEL_GRACE_MS
Default grace window between SIGTERM and SIGKILL for cancelled calls.

Functions§

run_apr
Spawn apr <args...> and wait synchronously. Shorthand for the non-cancellable path used by every tool except apr.run.
run_apr_cancellable
Spawn apr <args...> cancellable via cancel_rx.
run_apr_streaming
Spawn apr <args...> and stream stdout line-by-line to on_line.
spawn_cancellable
Test-visible generic over the binary name. run_apr_cancellable is the "apr"-bound wrapper clients should use in production code.
spawn_streaming
Generic-over-program variant of run_apr_streaming used by tests that need to inject a mock subprocess.