mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
fix(bionic): stop waiting 90 s for a program that already ended
launch.sh waited up to 90 s for a process named like the program before it waited for the program to end. A program that ends within a second - Steam's install-script evaluator when it has nothing to do - was never seen, so every real evaluator run held the game's start back by 90 s. The wait now also ends when the started Wine process is gone and no program of this prefix is left besides Wine's own services (wineserver, services.exe, winedevice.exe, plugplay.exe, explorer.exe, svchost.exe, rpcss.exe, conhost.exe, start.exe) and this script's window tagger. A launcher that leaves a game running is waited for as before. Only the app's own processes are read. Tested in Android's shell on the Pocket FIT with stand-in processes: program gone -> the wait ends at once; a child still running in the prefix -> the wait goes on until it ends; only the tagger or another prefix's program left -> the wait ends at once.
This commit is contained in:
1 parent
d0796720b8
commit
39a3535eb5
1 file changed
+20
-1
@@ -227,6 +227,20 @@ prefix_busy() { # a process of this prefix is running
|
||||
return 1
|
||||
}
|
||||
|
||||
programs_left() { # a program of this prefix is still running, apart from Wine's own services and this script's helpers
|
||||
for p in /proc/[0-9]*; do
|
||||
q=${p#/proc/}
|
||||
[ -O "$p" ] || continue
|
||||
[ "$q" = "$$" ] || [ "$q" = "${GT:-x}" ] && continue
|
||||
c=; read -r c < "$p/comm" 2>/dev/null
|
||||
case "$c" in
|
||||
""|wineserver|services.exe|winedevice.exe|plugplay.exe|explorer.exe|svchost.exe|rpcss.exe|conhost.exe|start.exe) continue ;;
|
||||
esac
|
||||
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qx "WINEPREFIX=$COMPAT/pfx" && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
stop_wine() { # wineserver -k, then whatever of this prefix is left (e.g. a game's crash reporter)
|
||||
wineserver_ -k 2>/dev/null
|
||||
sleep 1
|
||||
@@ -360,7 +374,12 @@ if [ "${SteamAppId:-0}" != 0 ]; then
|
||||
fi
|
||||
trap 'echo "$(date +%H:%M:%S) stopped by Steam"; [ -n "$GT" ] && kill $GT 2>/dev/null; stop_wine; exit 0' TERM INT HUP
|
||||
n=0
|
||||
while [ $n -lt 90 ] && [ -z "$(game_pids)" ]; do sleep 1; n=$((n + 1)); done
|
||||
while [ $n -lt 90 ] && [ -z "$(game_pids)" ]; do
|
||||
# A program that ended before it was seen (Steam's install-script step takes about a second) leaves nothing
|
||||
# to wait for; a launcher that left a game running is still waited for as before.
|
||||
if [ $n -ge 2 ] && ! kill -0 $WP 2>/dev/null && ! programs_left; then break; fi
|
||||
sleep 1; n=$((n + 1))
|
||||
done
|
||||
echo "$(date +%H:%M:%S) game process $(game_pids | tr '\n' ' ')after ${n}s"
|
||||
while [ -n "$(game_pids)" ]; do sleep 2; done
|
||||
echo "$(date +%H:%M:%S) game exited"
|
||||
|
||||
Reference in new issue
Block a user