From 80ac25d9f7aeea84d27116af8f05f74d4da1802a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Thu, 11 Apr 2024 17:26:21 +0200 Subject: [PATCH] Fix loop issues --- startup.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/startup.sh b/startup.sh index e58f995..a3a257a 100644 --- a/startup.sh +++ b/startup.sh @@ -32,17 +32,19 @@ pids+=($!) # Fonction pour surveiller la fermeture de l'IHM monitor_all() { - # Attendre que un des programmes se termine - for pid in "${pids[@]}"; do - if wait $pid; then - echo "Program with PID $pid has terminated, stopping other programs" - pkill -P $$ -f "lidar|arucoDetector|ihm_robot" - sleep 1 - pkill -P $$ -f "socketServer" - break - fi + while true; do + # Attendre que un des programmes se termine + for pid in "${pids[@]}"; do + if ! kill -0 $pid 2>/dev/null; then + echo "Program with PID $pid has terminated, stopping other programs" + pkill -P $$ -f "lidar|arucoDetector|ihm_robot" + sleep 1 + pkill -P $$ -f "socketServer" + return + fi + done + sleep 1 done - echo "All programs have terminated" } # Démarrer la fonction de surveillance en arrière-plan