View previous topic :: View next topic |
Author |
Message |
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Sun May 22, 2011 4:45 pm Post subject: fool-proof killing of games in WINE |
|
|
My wife started playing on the pc lately, mostly playing hidden object games under WINE. Some of them don't always work flawless, i.e. crashing somewhere and leaving X11/GNOME corrupted.
Since she's not able to fix these things herself, ie. can't handle `ps`, `kill`, etc, I'd like to have a fool-proof solution, which I can bind to some hotkey.
Basically, everything related to wine, ie wineserver, $game.exe, etc should be killed, first asking to game/wine to shutdown gracefully and if that does not work, kill it with force.
Since all here games are launched from /home/user/spiele, which is a symlink to .wine/drive_c/games/, I already wrote a script, grepping `ps` for 'spiele' (which is unique here), 'awk'ing out the pid and then pass it to kill, checking again a few seconds later and pass the pid to 'kill -9' if it's still running.
Now, that sometimes works and sometimes it does not, leaving a blank screen under X with just the cursor showing. A solution to this is obviously killing X, which in turn respawns gdm. But of course, this also trashes other open applications and in the worst case scenario also unsaved data, ie documents she's working on.
So I'd be happy, if someone could provide a nice/better working solution, except installing windows. I could make sudo available, if it's needed for some tasks, but I don't want to bother her with the shell, ie. as much as possible should be automated. Thanks for your help. _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
Posted: Sun May 22, 2011 5:08 pm Post subject: |
|
|
2 points:
1. Always run wine games in a separate instance of xorg, so you can kill it easily with Alt-Ctrl-Backspace. There's two methods:
a) Run xinit, e.g.:
Code: | export WINEPREFIX=$HOME/.wine-vicecity
export WINEDEBUG="fixme-all,err-all"
dir="$WINEPREFIX/drive_c/GTA Vice City"
cd "${dir}" && nice -n -3 xinit /usr/bin/wine gta-vc.exe -- :1 -a 1 -t 1 & |
b) Start a new xorg first, e.g.:
Code: | if [[ -e /tmp/.X1-lock ]] ; then
echo "Is already running, according to the lockfile."
echo "To clear: rm /tmp/.X1-lock"
else
X -br -ac -dpi 120 -depth 24 -once :1 &
xpid=$!
sleep 1
if [[ "${xpid}" != "" ]] ; then
export DISPLAY=:1
Terminal &
fi
fi |
2. Use e.g. the following to kill all wine processes. I don't know of a more elegant way.
Code: | wineserver -k
for f in wine winedbg winetricks wineserver ravenshield homeworld2 thief{,.exe} thief2{,.exe} vampire{,.exe} RelicCOH.exe oblivion plugplay.exe wineboot.exe cmd.exe xrEngine.exe steam Steam.exe TNM.exe javaw C:\windows\system32\rpcss.exe ; do
if [[ -n $(pidof $f) ]] ; then
killall $f 2>/dev/null
sleep 2
killall -9 $f 2>/dev/null
fi
done
killall services.exe 2>/dev/null
killall explorer.exe 2>/dev/null
killall winedevice.exe 2>/dev/null
kill $(pidof "C:\windows\system32\plugplay.exe") 2>/dev/null |
|
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Sun May 22, 2011 6:21 pm Post subject: |
|
|
Mh, may write some kind of wrapper and link this to .exe-files to accomplish this, but first I'll have to find out what the overhead for running another instance of X is, since her machine is far from being powerful.
As for the kill-stuff, I'll see how far that brings me, thanks so far. _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
salahx Guru
Joined: 12 Mar 2005 Posts: 530
|
Posted: Sun May 22, 2011 7:45 pm Post subject: |
|
|
As for approach (2) You could do the same thing systemd does: Place wine into its own cgroup. Then you can just walk over each process in the group (using cgroup.proc) and kill each process off. |
|
Back to top |
|
|
Mad Merlin Veteran
Joined: 09 May 2005 Posts: 1155
|
Posted: Wed May 25, 2011 2:12 pm Post subject: |
|
|
This would be a good start:
Code: | kill $(pgrep .exe) $(pgrep .EXE); wineserver -k |
_________________ Game! - Where the stick is mightier than the sword!
Last edited by Mad Merlin on Thu May 26, 2011 3:01 am; edited 2 times in total |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
wolfieh n00b
Joined: 17 Nov 2009 Posts: 54
|
Posted: Thu May 26, 2011 1:00 am Post subject: |
|
|
killall TheGameExecutable.exe
if you don't know the name find it with "pstree" or "ps aux | grep gamename" |
|
Back to top |
|
|
Mad Merlin Veteran
Joined: 09 May 2005 Posts: 1155
|
Posted: Thu May 26, 2011 3:01 am Post subject: |
|
|
wolfieh wrote: | killall TheGameExecutable.exe
if you don't know the name find it with "pstree" or "ps aux | grep gamename" |
This is often not enough, SC2 ends up spawning several processes that need to be killed (as it hangs on exit). For that, I ended up doing: Code: | kill $(pgrep -f windows; pgrep -f wineserver; pgrep StarCraft; pgrep -f SC2; pgrep winedbg) |
_________________ Game! - Where the stick is mightier than the sword! |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Thu May 26, 2011 3:24 am Post subject: |
|
|
Besides what @MadMerlin sad, the name of the .exe would have to be know, which would require some kind of wrapper.
I'll try some of your suggestions later, but the pgrep thingies look best so far to me. _________________ ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. |
|
Back to top |
|
|
celas n00b
Joined: 03 Mar 2003 Posts: 13 Location: UK
|
Posted: Fri Jun 03, 2011 6:51 am Post subject: |
|
|
Try using "wineboot -k" at a console |
|
Back to top |
|
|
|