diff --git a/start.sh b/start.sh index 52320ce..363233d 100755 --- a/start.sh +++ b/start.sh @@ -1,16 +1,16 @@ #!/bin/sh - +LANG="C" cleanup() { + trap - INT EXIT TERM echo "[DPS] Cleaning up..." - pkill $backend_pid # pkill because subshells - pkill $frontend_pid + pgrep -P "$backend_pid" | xargs kill -TERM > /dev/null 2>&1 + pgrep -P "$frontend_pid" | xargs kill -TERM > /dev/null 2>&1 echo "[DPS] Cleaned up..." exit } -# Trap INT (Ctrl+C) -trap cleanup INT +trap cleanup INT EXIT TERM echo "[DPS] trapped" cd ./00-backend @@ -25,4 +25,5 @@ echo "[DPS] Frontend started with PID $frontend_pid" echo "[DPS] Ctrl+C to stop" # Wait for cleanup -wait +wait $backend_pid +wait $frontend_pid