Skip to main content

Module exec

Module exec 

Source

Structs§

LimitedProcessOutput
Wait for a child process with output-size and time limits. Kills the process if either limit is exceeded, returning what was captured so far. Prevents unbounded memory growth on commands that produce massive output (e.g. rg -i "pattern" over a large tree).
ShellDispatchObservation
Result of dispatching an admitted shell execution.

Enums§

PreparedShellExecution
An allowlist-admitted shell execution that owns the effective command or the original pre-split argv.

Constants§

MAX_CALL_TIMEOUT_MS
Hard ceiling for a per-call timeout_ms override: generous enough for any legitimate build/release job, low enough that a typo’d value cannot wedge the executor for days.
STDERR_LABEL
Label inserted between stdout and stderr of a FAILED command so the agent can attribute the error to the right stream instead of guessing — and never has to re-run the command raw just to locate the failure. See #809 / #812.

Functions§

allowlist_gate
Shared allowlist gate for the CLI shell entrypoints — -c (via exec) and -t (via exec_argv). Both must apply the SAME boundary so the track path (the default shell hook) cannot be weaker than the compress path.
combine_streams
Join captured stdout and stderr for display/recovery. On failure (non-zero exit) with both streams present, a labeled delimiter separates them; success output keeps the plain stdout\nstderr shape (determinism, #498).
exec
exec_argv
Execute a command from pre-split argv without going through sh -c. Used by -t mode when the shell hook passes "$@" — arguments are already correctly split by the user’s shell, so re-serializing them into a string and re-parsing via sh -c would risk mangling complex quoted arguments (em-dashes, #, nested quotes, etc.).
execute_prepared
Execute an allowlist-admitted value through the existing post-gate routes. Admission is complete before this function runs; no allowlist check belongs here. Dispatch is considered attempted before entering a child helper, so a spawn failure with exit 127 is still an attempted dispatch.
prepare_exec
Prepare a shell command, applying wrapper unwrapping, nested-command collapsing, and the allowlist gate exactly once.
prepare_exec_argv
Prepare pre-split argv without reparsing it through a shell.
reap_within
Reap a child that has exited or was just killed, within budget.
shell_timeout_with_override
shell_timeout with an optional per-call override (ctx_shell’s timeout_ms arg). Precedence: operator env pin (LEAN_CTX_SHELL_TIMEOUT_MS)
wait_with_limits_captured