mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
The routine only carried an EXIT trap, so a run terminated by the enclosing `timeout` in distros.sh:128 left no rescue diagnostics, no playwright reports and no teardown — the exact case where the artifacts matter most. Add a TERM trap and make the handler take the status as an argument, so EXIT keeps using `$?` while TERM passes 143 explicitly. The `_teardown_done` latch is required because the EXIT trap still fires after the TERM trap; without it the whole collect-and-teardown block, including its 1500s and 900s timeouts, would run twice. This works because GNU timeout signals the whole process group: bash defers a trap while it waits on a foreground child, so a bare kill to the script PID alone would not surface it until that child exited. Reproduced under the real shape (timeout -k): TEARDOWN rc=143, exactly once, after 2.01s. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>