Created
September 22, 2022 00:48
-
-
Save moonexpr/bf0df7f87209838ecea32e8d51c54614 to your computer and use it in GitHub Desktop.
wine_killall: Terminates all wine instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# From: | |
# https://askubuntu.com/questions/52341/how-to-kill-wine-processes-when-they-crash-or-are-going-to-crash/732320#732320 | |
wine_cellar="${HOME}/.local/share/wine" | |
if (($#)); then | |
if [[ -e "${wine_cellar}/$1" ]]; then | |
WINEPREFIX="${wine_cellar}/$1" | |
shift | |
elif [[ "${1:0:1}" != "-" ]]; then | |
echo "ERROR: Didn't understand argument '$1'?" >&2; | |
exit 1 | |
fi | |
fi | |
if ((${#WINEPREFIX})); then | |
pids=$( | |
grep -l "WINEPREFIX=${WINEPREFIX}$" $( | |
ls -l /proc/*/exe 2>/dev/null | | |
grep -E 'wine(64)?-preloader|wineserver' | | |
perl -pe 's;^.*/proc/(\d+)/exe.*$;/proc/$1/environ;g;' | |
) 2> /dev/null | | |
perl -pe 's;^/proc/(\d+)/environ.*$;$1;g;' | |
) | |
else | |
pids=$( | |
ls -l /proc/*/exe 2>/dev/null | | |
grep -E 'wine(64)?-preloader|wineserver' | | |
perl -pe 's;^.*/proc/(\d+)/exe.*$;$1;g;' | |
) | |
fi | |
if ((${#pids})); then | |
set -x | |
kill $* $pids | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment