Changing the timeout until Wine closes
-
- Level 2
- Posts: 19
- Joined: Thu Sep 27, 2012 5:32 pm
Changing the timeout until Wine closes
Normally if all applications related to the Wine instance are closed there will remain a few processes (/usr/bin/wineserver, C:\windows\system32\services.exe, C:\windows\system32\winedevice.exe MountMgr, C:\windows\system32\plugplay.exe, C:\windows\system32\explorer.exe /desktop) for several seconds until Wine is completely closed. Is there maybe a way to change the timeout then these processes will awake and exit? In my case I would prefer if these processes would close immediately if all applications are closed.
- olivierfrdierick
- Level 5
- Posts: 258
- Joined: Thu Sep 13, 2012 12:09 pm
Re: Changing the timeout until Wine closes
There is a -p option to the wineserver command line.
It is documented here: http://www.winehq.org/docs/wineserver
I made some tests with it but could not make wineserver quit sooner than the 3 seconds default delay.
Longer delay works as expected, but shorter has no visible effect, at least on my computer.
For the record, to use the -p command line option without running wineserver explicitly I followed these steps:
It is documented here: http://www.winehq.org/docs/wineserver
I made some tests with it but could not make wineserver quit sooner than the 3 seconds default delay.
Longer delay works as expected, but shorter has no visible effect, at least on my computer.
For the record, to use the -p command line option without running wineserver explicitly I followed these steps:
- Rename the wineserver executable to something else.
Code: Select all
sudo mv /usr/lib/i386-linux-gnu/wine/wineserver /usr/lib/i386-linux-gnu/wine/realwineserver
- Create a wrapper script that replaces the wineserver executable:
Code: Select all
sudo nano /usr/lib/i386-linux-gnu/wine/wineserver
- Put this content into the wrapper script:"$@" is to pass any options given to the wrapper script to realwineserver.
Code: Select all
#!/bin/bash /usr/lib/i386-linux-gnu/wine/realwineserver -p0 "$@"
- Make the wrapper script executable:
Code: Select all
sudo chmod +x /usr/lib/i386-linux-gnu/wine/wineserver
- Setting wineserver command line options directly in the WINESERVER variable is invalid and the variable is then simply ignored.
- The name and directory where the wrapper script is located can be anything as long as you set the WINESERVER variable to point to it before running any WINE command.
If you set the name and directory of the wrapper script to the original name and location of the wineserver executable, then you do not need to set WINESERVER. - The wineserver executable had to be renamed otherwise the command line options are ignored even if they are passed by the wrapper script.
- The above instructions must be adapted to whatever configuration you have and I do not guarantee it'll work.
-
- Level 2
- Posts: 19
- Joined: Thu Sep 27, 2012 5:32 pm
Re: Changing the timeout until Wine closes
Thanks for the information. I have tried this now and increasing and even decreasing the timeout works as expected (I'm on Wine 1.7.19). Also using -p0 does immediately close the wineserver which I was looking for. But I'm wondering if there is a less hackish way to achieve a different default option than using a wrapper script (for example registry keys for default options).
- olivierfrdierick
- Level 5
- Posts: 258
- Joined: Thu Sep 13, 2012 12:09 pm
Re: Changing the timeout until Wine closes
I couldn't find any other way to set wineserver options other than on the command line.
The only other way I can think of is to modify the source code to either change the default persistence value or add code to use a config file, which are not viable solutions.
All of this is going to break when Wine gets updated.
My wrapper script would also break.
If it wasn't necessary to rename the wineserver executable then script solution wouldn't break.
I have to rename that file because the WINESERVER variable is ignored when wine finds its wineserver executable where it expects it to be.
Only if the wineserver file is missing do wine use the WINESERVER variable (Or at least it does so on my computer).
I've seen this with wine 1.4.1 from debian stable repository and wine 1.7.19 from playonlinux (both x86 and amd64).
Before filing a bug about this I would like other people to confirm that the WINESERVER variable works as expected or not.
To test the WINESERVER variable I did:
Furthermore, I also found that copying the wineserver executable in a directory that comes first in the PATH variable is ignored by Wine:Still uses wineserver from /usr/lib/i386-linux-gun/wine (Of course I made sure no other WINESERVER or WINE* variable where set).
But again, if wineserver is moved from /usr/lib/i386-linux-gnu/wine, then wine finds the wineserver in /home/olivier/thisisatest/bin.
If this last snipet of code did work, it would have been easier to setup the wrapper script as a user.
By the way, someone filed an enhancement request for a variable to disable wineserver persistence.
A variable to SET persistence would be better, but anyway maybe you can join him to support his request? bug 36040
The only other way I can think of is to modify the source code to either change the default persistence value or add code to use a config file, which are not viable solutions.
All of this is going to break when Wine gets updated.
My wrapper script would also break.
If it wasn't necessary to rename the wineserver executable then script solution wouldn't break.
I have to rename that file because the WINESERVER variable is ignored when wine finds its wineserver executable where it expects it to be.
Only if the wineserver file is missing do wine use the WINESERVER variable (Or at least it does so on my computer).
I've seen this with wine 1.4.1 from debian stable repository and wine 1.7.19 from playonlinux (both x86 and amd64).
Before filing a bug about this I would like other people to confirm that the WINESERVER variable works as expected or not.
To test the WINESERVER variable I did:
Code: Select all
sudo cp /usr/lib/i386-linux-gnu/wine/wineserver /usr/lib/i386-linux-gnu/wine/wineserver-olivier WINESERVER=/usr/lib/i386-linux-gnu/wine/wineserver-olivier wine notepad.exe
- Open system monitor in parallel and check wineserver process name.
It was wineserver - Quit notepad, and wait for wineserver process to finish. Then
Code: Select all
sudo mv /usr/lib/i386-linux-gnu/wine/wineserver /usr/lib/i386-linux-gnu/wine/wineserver-cannot-be-found WINESERVER=/usr/lib/i386-linux-gnu/wine/wineserver-olivier wine notepad.exe
- Check the winserver process name in system monitor.
It is wineserver-olivier - Close notepad, wait for wineserver-olivier process to finish.
- Thenwine outputs
Code: Select all
wine notepad.exe
Code: Select all
wine: could not exec wineserver
- Then replace every thing where it should be
Code: Select all
sudo mv /usr/lib/i386-linux-gnu/wine/wineserver-cannot-be-found /usr/lib/i386-linux-gnu/wine/wineserver sudo rm /usr/lib/i386-linux-gnu/wine/wineserver-olivier
Furthermore, I also found that copying the wineserver executable in a directory that comes first in the PATH variable is ignored by Wine:
Code: Select all
mkdir -P /home/olivier/thisisatest/bin
sudo cp /usr/lib/i386-linux-gnu/wine/wineserver /home/olivier/thisisatest/bin/wineserver
PATH="/home/olivier/thisisatest/bin:$PATH"
wine notepad.exe
But again, if wineserver is moved from /usr/lib/i386-linux-gnu/wine, then wine finds the wineserver in /home/olivier/thisisatest/bin.
If this last snipet of code did work, it would have been easier to setup the wrapper script as a user.
By the way, someone filed an enhancement request for a variable to disable wineserver persistence.
A variable to SET persistence would be better, but anyway maybe you can join him to support his request? bug 36040
-
- Level 2
- Posts: 19
- Joined: Thu Sep 27, 2012 5:32 pm
Re: Changing the timeout until Wine closes
I remember that I got on my testing some troubles there too. On making now a test again:olivierfrdierick wrote:I have to rename that file because the WINESERVER variable is ignored when wine finds its wineserver executable where it expects it to be.
/tmp/wineserver contains:
Code: Select all
#!/bin/bash
/usr/bin/wineserver -p0
The manpage says that this is the correct behavior if WINESERVER is not set.olivierfrdierick wrote:Furthermore, I also found that copying the wineserver executable in a directory that comes first in the PATH variable is ignored by Wine
I have made now a post there to suggest to control the timeout instead using a flag with an environment variable.olivierfrdierick wrote:By the way, someone filed an enhancement request for a variable to disable wineserver persistence.
A variable to SET persistence would be better, but anyway maybe you can join him to support his request? bug 36040
I have also made some tests how to solve this problem. My idea was to use aliases but I could only partly solve the problem. Here is the current code:
Code: Select all
function wineserver_wrapper
{
arguments=
explicit_persistent=false
while [ "$1" != '' ]
do
if [[ "$1" =~ ^-p[0-9]*?$ ]]
then
explicit_persistent=true
fi
arguments="$arguments"' '"$1"
shift
done
if [ $explicit_persistent = false ]
then
arguments=-p0' '"$arguments"
fi
wineserver $arguments
}
alias wine='wineserver; wine'
alias wineserver=wineserver_wrapper