diff --git a/scripts/sold-client-ports.py b/scripts/sold-client-ports.py index bd077c2..94a3768 100755 --- a/scripts/sold-client-ports.py +++ b/scripts/sold-client-ports.py @@ -54,7 +54,21 @@ def parse(text): def fifa_running(): - return bool(ssh("pgrep -f FIFA17.exe || true").strip()) + """True if a real FIFA 17 process exists on the client. + + Matches /proc//comm exactly rather than `pgrep -f FIFA17.exe`: the pattern + form self-matched the remote shell running it (the SSH command line contains the + literal string), so the guard was permanently stuck ON and could never report + "not running". comm is the executable name, so the shell reads as zsh/bash and + only a genuine FIFA process matches. Still fail-closed: any read error or + unexpected output is treated as "running". + """ + out = ssh( + "for d in /proc/[0-9]*; do " + "[ -r \"$d/comm\" ] && [ \"$(cat $d/comm 2>/dev/null)\" = FIFA17.exe ] " + "&& echo ${d#/proc/}; done || true" + ).strip() + return bool(out) def show():