[eric] build: the cancel trap fires only on INT/TERM and walks the tree; the EXIT variant flipped a green build's exit code to 1 under set -e

This commit is contained in:
ciregenz
2026-08-11 10:57:14 -07:00
parent a7c1a8256e
commit c7c71b6ea0
+13 -5
View File
@@ -1,11 +1,19 @@
#!/bin/bash
set -euo pipefail
# Killing this build (Ctrl-C, or a parent that gets killed) used to orphan electron-builder's 7za
# child, which then sat for HOURS holding a ~300MB archive open (found one aged 20h). Run in our own
# process group and sweep it on any exit so a cancelled build takes its whole tree with it (ENG-247).
set -m
trap 'pkill -P $$ 2>/dev/null; kill -- -$$ 2>/dev/null' EXIT INT TERM
# Killing this build (Ctrl-C, pkill) used to orphan electron-builder's 7za child, which then sat
# for HOURS holding a ~300MB archive open (found one aged 20h). On INT/TERM, walk and kill the whole
# descendant tree. Deliberately NOT on EXIT: a trap that fires on normal completion flips a green
# build's exit code under set -e and publish.sh would read success as failure (ENG-247).
kill_descendants() {
local pid kids
for pid in "$@"; do
kids=$(pgrep -P "$pid" 2>/dev/null || true)
[ -n "$kids" ] && kill_descendants $kids
kill -TERM "$pid" 2>/dev/null || true
done
}
trap 'kill_descendants $(pgrep -P $$ 2>/dev/null || true); exit 130' INT TERM
# Master build script for the OpenSwarm desktop app.
#