Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Waiting for wine to finish running

Tags:

bash

wine

My current script looks like this:

cd ~/.wine/drive_c/
echo "test123" > foo$$.txt
wine start "C:\foo$$.txt"
wineserver -w
echo "Wine is done!"

which works fine when only one program is running in wine at a time. However if I run this a second time, before the first program is done, both scripts will wait for each others programs to exit.

This does not work:

cd ~/.wine/drive_c/
echo "test123" > foo$$.txt
$(wine start "C:\foo$$.txt") &
wait ${!}
echo "Wine is done!"

as it will exit before you close the text editor.

I need to use the start command, because I want a file to be run with its default editor/viewer.

like image 374
Tyilo Avatar asked Oct 15 '25 08:10

Tyilo


1 Answers

wine <program> waits until the program exits. wine start program does not.

A summary:

  • wine <program> starts the program and waits until it is finished. I recommend using this method.
  • wine start <program> starts the program and immediately exits without waiting. The program will keep running in the background.
  • wine start \wait <program> starts the program and waits until it is finished. This is the same behavior as wine <program>.
  • wineserver --wait waits until all programs and all services in Wine are finished. This command does not launch any program itself but waits for existing programs and services.

Services like services.exe, plugplay.exe, and winedevice.exe keep on running a few seconds after the last program finishes, and wineserver --wait also waits until these services exit.

Some of these services hold state and write their state (and the registry) to disk when they exit. So if you want to backup or remove your wine prefix, make sure to wait until these services have exited.

like image 63
Merlijn Sebrechts Avatar answered Oct 17 '25 03:10

Merlijn Sebrechts