Linux shutdown hangs while closing wine app

Questions about Wine on Linux
Locked
Potter
Level 2
Level 2
Posts: 17
Joined: Thu Aug 30, 2018 10:59 am

Linux shutdown hangs while closing wine app

Post by Potter »

When gnome starts I have a wine app auto-starting via .desktop file.
When ending the gnome session gnome is to terminate it. But something goes wrong. Gnome comes down, and the log down messages are showing up. Then, suddenly they stop, saying:
User1000.service /stop runing (46s / 2min): job app-gnome-MYAPP-1794..scope /stop running (47s /1m 30s)
Now MYAPP, the wine app, counts second by second for upto 2 minutes. Then Linux proceeds shutting down the computer, presenting the normal clean up messages.

I changed the auto-starting wine app with others - same behaviour. And the issue is not about waiting for saving changes in the app. Shutting down the pc by the gnome way is enough.

What is the idea on terminating wine apps automatically?
Will I have to do it manually before shutting down linux?

Environment is: Wine 8.02, 32bit arch WINEPREFIX, Debian 12, gnome. Desktop PC.

Thank You for help.
Potter
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Linux shutdown hangs while closing wine app

Post by jkfloris »

Probably (some part of) the program or another Windows service keeps running when a SIGTERM is sent to the program. You can check this with:

Code: Select all

# find the PID of the program:
pgrep -a '.exe'
18738 C:\windows\system32\services.exe
18741 C:\windows\system32\svchost.exe -k LocalServiceNetworkRestricted
18747 C:\windows\system32\winedevice.exe
18755 C:\windows\system32\winedevice.exe
18766 C:\windows\system32\plugplay.exe
18780 C:\your\program\MYAPP.exe         <-- Remember this number
18786 C:\windows\system32\explorer.exe /desktop
18791 C:\windows\system32\rpcss.exe

# Stop the program:
kill 18780

# Verify that the program has stopped:
pgrep -a '.exe'
If some Windows programs are still running after you stop the program, you can stop all Wine programs with:

Code: Select all

wineserver -k
You can also add this line to ~/.bash_logout to shut down all Wine processes when the user logs out.
Potter
Level 2
Level 2
Posts: 17
Joined: Thu Aug 30, 2018 10:59 am

Re: Linux shutdown hangs while closing wine app

Post by Potter »

Thank You for reply,

wineserver -k stops all wine processes, when writing into terminal. pgrep shows that.
wineboot -es works, too.
Putting it to .bash_logout did not work. (I expected it to do so, when I at least called up a terminal before.)
All other ways I tried hang at the same point, sometimes not even showing log down messages any more, only blinking cursor.
When I call another tty terminal (CTRL+ALT+F4), login as root, typing "shutdown -h now", does not help either.

All smells like: not enough time for OS to terminate autostarted wine processes, don't you think so?
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Linux shutdown hangs while closing wine app

Post by jkfloris »

Which programs keep running when you close the main program?
Potter
Level 2
Level 2
Posts: 17
Joined: Thu Aug 30, 2018 10:59 am

Re: Linux shutdown hangs while closing wine app

Post by Potter »

These are still running:

2029 C:\windows\system32\services.exe
2075 C:\windows\system32\svchost.exe -k LocalServiceNetworkRestricted
2086 C:\windows\system32\winedevice.exe
2200 C:\windows\system32\winedevice.exe
2785 C:\windows\system32\plugplay.exe
2797 C:\windows\system32\rpcss.exe
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Linux shutdown hangs while closing wine app

Post by jkfloris »

Strange, those are just the normal Wine processes.
What does the .desktop file look like?
Potter
Level 2
Level 2
Posts: 17
Joined: Thu Aug 30, 2018 10:59 am

Re: Linux shutdown hangs while closing wine app

Post by Potter »

Like this, which is current on:

Code: Select all

[Desktop Entry]
Name=Terminplaner prefix32
#Exec=env WINEPREFIX="/home/joerguser/prefix32" wine "/home/joerguser/prefix32/drive_c/Program Files/TerminplanerNET/Terminplaner.exe"
Exec=env WINEPREFIX="/home/joerguser/prefix32" wine "c:\Program Files\TerminplanerNET\Terminplaner.exe"
Terminal=false
Type=Application
StartupNotify=true
Path=/home/joerguser/prefix32/drive_c/Program Files/TerminplanerNET
Icon=0F61_Terminplaner.0
StartupWMClass=Terminplaner.exe
desktop-file-validate says alright.
jkfloris
Level 12
Level 12
Posts: 3141
Joined: Thu Aug 14, 2014 10:10 am

Re: Linux shutdown hangs while closing wine app

Post by jkfloris »

I don't know why Wine is having trouble shutting down. Your .desktop file looks fine.
Instead of a .desktop file, you can also use a systemd user service file.

Create a terminplaner.service file in the ~/.local/share/systemd/user/ directory.
(Create the systemd and user directory if they do not exist.)
With the following contents:

Code: Select all

[Unit]
Description=Run Terminplaner - Wine application

[Service]
Type=forking
Environment="WINEPREFIX=/home/joerguser/prefix32/"
ExecStart=/usr/bin/wine start /unix "/home/joerguser/prefix32/drive_c/Program Files/TerminplanerNET/Terminplaner.exe"
ExecStop=/usr/bin/wineserver -k

[Install]
WantedBy=graphical-session.target
Test and enable the service file:

Code: Select all

systemctl --user start terminplaner
systemctl --user stop terminplaner
systemctl --user enable terminplaner
Potter
Level 2
Level 2
Posts: 17
Joined: Thu Aug 30, 2018 10:59 am

Re: Linux shutdown hangs while closing wine app

Post by Potter »

Thank You very much. Seems to be a stable solution. Linux is down in a hurry.
It is great that there is a systemd way for users. I was in hope for something like that.
:D
Locked