mirror of
https://github.com/modelec/Initialisation.git
synced 2026-03-18 21:30:40 +01:00
Replace Sigterm by sigkill
This commit is contained in:
17
startup.sh
17
startup.sh
@@ -6,12 +6,13 @@
|
|||||||
|
|
||||||
# Stocker les PIDs des programmes en arrière-plan dans une array
|
# Stocker les PIDs des programmes en arrière-plan dans une array
|
||||||
pids=()
|
pids=()
|
||||||
|
pidserver=()
|
||||||
|
|
||||||
# Démarrer le serveur TCP
|
# Démarrer le serveur TCP
|
||||||
echo "Starting the TCP server"
|
echo "Starting the TCP server"
|
||||||
/home/modelec/Serge/TCPSocketServer/build/socketServer &
|
/home/modelec/Serge/TCPSocketServer/build/socketServer &
|
||||||
echo "TCP server pid" $! > /home/modelec/Serge/TCP_pid.txt
|
echo "TCP server pid" $! > /home/modelec/Serge/TCP_pid.txt
|
||||||
pids+=($!)
|
pidserver+=($!)
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# Démarrer le Lidar
|
# Démarrer le Lidar
|
||||||
@@ -69,10 +70,18 @@ monitor_all() {
|
|||||||
for pid in "${pids[@]}"; do
|
for pid in "${pids[@]}"; do
|
||||||
if ! kill -0 $pid 2>/dev/null; then
|
if ! kill -0 $pid 2>/dev/null; then
|
||||||
echo "Program with PID $pid has terminated, stopping other programs"
|
echo "Program with PID $pid has terminated, stopping other programs"
|
||||||
pkill -P $$ -f "lidar|arucoDetector|ihm_robot|connectors|servo_motor|tirette"
|
for other_pid in "${pids[@]}"; do
|
||||||
sleep 1
|
if [ "$other_pid" != "$pid" ]; then
|
||||||
|
if ps -p $other_pid -o comm= | grep -q "socketServer"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
kill -SIGKILL $other_pid 2>/dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
echo "Stopping the TCP server"
|
echo "Stopping the TCP server"
|
||||||
pkill -P $$ -f "socketServer"
|
for server_pid in "${pidserver[@]}"; do
|
||||||
|
kill -SIGKILL $server_pid 2>/dev/null
|
||||||
|
done
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user