From e6dd2056c46728f03f704bc57ef83bdc74b5cd8e Mon Sep 17 00:00:00 2001 From: Greelan <53196309+Greelan@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:46:05 +1100 Subject: [PATCH] Arma3: improve exit handling for headless clients (#476) --- arma3runhc.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arma3runhc.sh b/arma3runhc.sh index de6cee4..0c675d1 100644 --- a/arma3runhc.sh +++ b/arma3runhc.sh @@ -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