Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
fool-proof killing of games in WINE
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Sun May 22, 2011 4:45 pm    Post subject: fool-proof killing of games in WINE Reply with quote

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
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Sun May 22, 2011 5:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Sun May 22, 2011 6:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 530

PostPosted: Sun May 22, 2011 7:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mad Merlin
Veteran
Veteran


Joined: 09 May 2005
Posts: 1155

PostPosted: Wed May 25, 2011 2:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Wed May 25, 2011 5:13 pm    Post subject: Reply with quote

Have you tried xkill, it works differently, if you create a hotkey for it your wife can use it http://linux.die.net/man/1/xkill
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
wolfieh
n00b
n00b


Joined: 17 Nov 2009
Posts: 54

PostPosted: Thu May 26, 2011 1:00 am    Post subject: Reply with quote

killall TheGameExecutable.exe

if you don't know the name find it with "pstree" or "ps aux | grep gamename"
Back to top
View user's profile Send private message
Mad Merlin
Veteran
Veteran


Joined: 09 May 2005
Posts: 1155

PostPosted: Thu May 26, 2011 3:01 am    Post subject: Reply with quote

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
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Thu May 26, 2011 3:24 am    Post subject: Reply with quote

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
View user's profile Send private message
celas
n00b
n00b


Joined: 03 Mar 2003
Posts: 13
Location: UK

PostPosted: Fri Jun 03, 2011 6:51 am    Post subject: Reply with quote

Try using "wineboot -k" at a console
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum