Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(ci): add cancel-aware CI helper script

Steven Enamakel4f30a7d05a67
diff --git a/scripts/ci-cancel-aware.sh b/scripts/ci-cancel-aware.sh
index ead3c8f293..8f7944241e 100755
--- a/scripts/ci-cancel-aware.sh
+++ b/scripts/ci-cancel-aware.sh
@@ -143,9 +143,15 @@ cleanup() {
# Kill the watchdog's in-flight `sleep`/`curl` too. Killing only the
# subshell orphans them, and the orphan keeps the inherited stderr open:
# a caller capturing this script's output then waits up to a full poll
- # interval for EOF after the command has already exited.
- pkill -TERM -P "$WATCHDOG_PID" 2>/dev/null || true
+ # interval for EOF after the command has already exited. Kill the
+ # subshell first so it cannot report its child's death on stderr.
+ local watchdog_children=""
+ watchdog_children="$(pgrep -P "$WATCHDOG_PID" 2>/dev/null || true)"
kill "$WATCHDOG_PID" 2>/dev/null || true
+ if [ -n "$watchdog_children" ]; then
+ # shellcheck disable=SC2086 # one PID per word
+ kill -TERM $watchdog_children 2>/dev/null || true
+ fi
fi
if [ -n "$CHILD_PID" ] && kill -0 "$CHILD_PID" 2>/dev/null; then