From c7c71b6ea0a9519d000e4eb9ccaf04f6b701fe3f Mon Sep 17 00:00:00 2001 From: ciregenz Date: Tue, 11 Aug 2026 10:57:14 -0700 Subject: [PATCH] [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 --- scripts/build-app.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/build-app.sh b/scripts/build-app.sh index 9ea4aa4f..35af0e16 100755 --- a/scripts/build-app.sh +++ b/scripts/build-app.sh @@ -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. #