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+=($!) }