From 891b875cd1f405bf85767f270b48f0caac50dfcd Mon Sep 17 00:00:00 2001 From: Deeman Date: Wed, 18 Feb 2026 17:38:26 +0100 Subject: [PATCH] fix dev_run.sh not stopping child processes on Ctrl-C run_with_label piped output through a while loop, so $! tracked the formatter PID instead of the actual command. Ctrl-C killed the formatters but left app/worker/css-watch running as orphans. Switch to process substitution so $! is the real command PID, and pkill -P children before killing tracked PIDs. Co-Authored-By: Claude Opus 4.6 --- padelnomics/scripts/dev_run.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/padelnomics/scripts/dev_run.sh b/padelnomics/scripts/dev_run.sh index 99e2554..fe75817 100755 --- a/padelnomics/scripts/dev_run.sh +++ b/padelnomics/scripts/dev_run.sh @@ -71,6 +71,8 @@ cleanup() { echo "" echo -e "${BOLD}Stopping all processes...${NC}" for pid in "${PIDS[@]}"; do + # Kill children first (e.g. make → tailwind), then the process itself + pkill -P "$pid" 2>/dev/null || true kill "$pid" 2>/dev/null || true done wait 2>/dev/null || true @@ -81,12 +83,11 @@ cleanup() { trap cleanup SIGINT SIGTERM # Prefix each line of a command's output with a colored label. +# Uses process substitution so $! is the actual command PID (not the formatter). run_with_label() { local color="$1" label="$2" shift 2 - "$@" 2>&1 | while IFS= read -r line; do - echo -e "${color}[${label}]${NC} ${line}" - done & + "$@" > >(while IFS= read -r line; do echo -e "${color}[${label}]${NC} ${line}"; done) 2>&1 & PIDS+=($!) }