Post

Kill all WINE process in linux

If your system has lots of orphan WINE process. Use this script to kill all of them.

~/.local/bin/kill-wine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
wine_cellar="${HOME}/.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
This post is licensed under CC BY 4.0 by the author.