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