Merge pull request 'fix: claude subprocess not killed on INT/TERM in cleanup trap (#530)' (#679) from fix/issue-530 into master

This commit is contained in:
johba 2026-03-13 11:26:02 +01:00
commit f1b64a448f

View file

@ -180,8 +180,12 @@ SNAP=$("$CAST" rpc anvil_snapshot --rpc-url "$RPC_URL" | tr -d '"')
log " Snapshot ID: $SNAP" log " Snapshot ID: $SNAP"
# Revert to the baseline snapshot on exit so subsequent runs start clean. # Revert to the baseline snapshot on exit so subsequent runs start clean.
CLAUDE_PID=""
cleanup() { cleanup() {
local rc=$? local rc=$?
if [[ -n "${CLAUDE_PID:-}" ]]; then
kill "$CLAUDE_PID" 2>/dev/null || true
fi
if [[ -n "${SNAP:-}" ]]; then if [[ -n "${SNAP:-}" ]]; then
"$CAST" rpc anvil_revert "$SNAP" --rpc-url "$RPC_URL" >/dev/null 2>&1 || true "$CAST" rpc anvil_revert "$SNAP" --rpc-url "$RPC_URL" >/dev/null 2>&1 || true
fi fi
@ -661,8 +665,11 @@ set +e
# omitting it causes the CLI to exit with an error, producing an empty stream log. # omitting it causes the CLI to exit with an error, producing an empty stream log.
timeout "$CLAUDE_TIMEOUT" claude -p --dangerously-skip-permissions \ timeout "$CLAUDE_TIMEOUT" claude -p --dangerously-skip-permissions \
--verbose --output-format stream-json \ --verbose --output-format stream-json \
"$PROMPT" >"$STREAM_LOG" 2>&1 "$PROMPT" >"$STREAM_LOG" 2>&1 &
CLAUDE_PID=$!
wait "$CLAUDE_PID"
AGENT_EXIT=$? AGENT_EXIT=$?
CLAUDE_PID=""
set -e set -e
if [[ $AGENT_EXIT -ne 0 ]]; then if [[ $AGENT_EXIT -ne 0 ]]; then