Skip to main content

Module exec

Module exec 

Source
Expand description

Process spawning and execution for the claude CLI.

Builds and runs the child process behind every command: applies the Claude client’s binary path, working directory, environment, and timeout, scrubs the CLAUDECODE env var so nested runs are not detected as recursive, drains stdout/stderr without deadlocking, and maps failures onto Error via from_command_failure. Both the async (tokio) and blocking (sync feature) paths live here.

By default every spawn places the child in its own Unix process group, and every async spawn sets kill_on_drop(true). Dropping an in-flight future SIGKILLs that group. Awaited cancellation and timeouts can first send a configured soft signal while draining output through a short grace. Descendants that leave the group require cooperative cleanup by the CLI; group signals cannot guarantee their termination. Blocking paths cannot be dropped mid-flight, so they have no drop-side equivalent.

Consequence of the group split: the child no longer shares the host’s terminal process group, so terminal-generated signals (Ctrl-C) do not reach it directly; terminating a run is the wrapper’s job, via drop, timeout, or an explicit kill. Terminal-attached hosts that want the terminal to stay the supervisor can opt out with ClaudeBuilder::process_group(false), trading group cleanup away: kills then reach only the direct child.

Structs§

CommandOutput
Raw output from a claude CLI invocation.

Functions§

die_with_parent_supported
Whether ClaudeBuilder::die_with_parent does anything on this platform.
run_claude
Run a claude command with the given arguments.
run_claude_allow_exit_codes
Run a claude command and allow specific non-zero exit codes.
run_claude_allow_exit_codes_sync
Blocking mirror of run_claude_allow_exit_codes.
run_claude_cancellable
Run a Claude command with an explicit cancellation signal.
run_claude_sync
Blocking mirror of run_claude. Available with the sync feature.
run_claude_with_retry
Run a claude command with an optional per-command retry policy override.
run_claude_with_retry_sync
Blocking mirror of run_claude_with_retry.
run_claude_with_stdin_prompt
Run claude, writing stdin_content to the child’s stdin rather than passing the prompt as argv.
run_claude_with_stdin_prompt_cancellable
Run Claude with a stdin prompt and an explicit cancellation signal.
run_claude_with_stdin_prompt_sync
Blocking mirror of run_claude_with_stdin_prompt.