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§
- Command
Output - Raw output from a claude CLI invocation.
Functions§
- die_
with_ parent_ supported - Whether
ClaudeBuilder::die_with_parentdoes 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 thesyncfeature. - 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_contentto 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.