Fix to take any program that crash (not only ihm) for putting serge in startup pos

This commit is contained in:
2024-04-02 13:15:51 +02:00
parent dd667fdb32
commit b70d028465
5 changed files with 21 additions and 12 deletions

View File

@@ -17,25 +17,32 @@ sleep 1
# Démarrer la caméra
echo "Starting the camera"
/mnt/win/Users/BreizhHardware/Nextcloud/Programation/C++/Modelec/Initialisation/test/test3.sh &
sleep 1
# Démarrer l'IHM
echo "Starting the IHM"
/mnt/win/Users/BreizhHardware/Nextcloud/Programation/C++/Modelec/Initialisation/test/test4.sh fullscreen &
# Fonction pour surveiller la fermeture de l'IHM
monitor_ihm() {
while pgrep -x "test4.sh" > /dev/null; do
sleep 1
# Fonction pour surveiller la fermeture de tous les programmes
monitor_all() {
local pids=$(pgrep -d ' ' -f "test1|test2|test3|test4")
# Attendre que l'un des programmes se termine
wait $pids
# Terminer tous les autres programmes
for pid in $pids; do
if ps -p $pid > /dev/null; then
echo "Program with PID $pid has terminated, stopping other programs"
pkill -P $$ -f "test1|test2|test3|test4"
break
fi
done
# Une fois l'IHM fermée, tuer tous les autres programmes
killall test1.sh
killall test2.sh
killall test3.sh
echo "All programs terminated."
echo "All programs have terminated"
}
# Démarrer la fonction de surveillance en arrière-plan
monitor_ihm &
monitor_all &
# Attendre que tous les programmes se terminent
wait

View File

@@ -2,4 +2,5 @@
while true; do
echo "test1"
sleep 1
done

View File

@@ -2,4 +2,5 @@
while true; do
echo "test2"
sleep 1
done

View File

@@ -2,4 +2,5 @@
while true; do
echo "test3"
sleep 1
done

View File

@@ -2,9 +2,8 @@
# Boucle pendant 10 secondes
SECONDS=0
while [ $SECONDS -lt 2 ]; do
while [ $SECONDS -lt 10 ]; do
echo "test4"
sleep 1
done
# Quitter le programme