Arma3: improve exit handling for headless clients (#476)

This commit is contained in:
Greelan 2023-10-11 13:46:05 +11:00 committed by GitHub
parent 2f6e0d03d7
commit e6dd2056c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,13 +38,14 @@ for i in $(seq 1 "$1"); do
done
# Monitor server process and terminate headless clients
# when server terminates
trap 'kill "${clients[@]}" >/dev/null 2>&1' SIGTERM
# when server terminates or SIGTERM/SIGINT received
trap 'for client in "${clients[@]}"; do kill "$client" >/dev/null 2>&1; done; wait' SIGTERM SIGINT
while true; do
if ! $netcommand -uln | grep -q ":$3 "; then
for client in "${clients[@]}"; do
kill "$client" >/dev/null 2>&1
done
wait
exit 0
fi
sleep 1