I have GTA San Andreas running in Wine, although when I exit the game it hangs in the terminal, and the process still has leftover resources, which causes it not to exit. So I've made this command which I think will loop over the lines in the output of the game and kill it when it finds leftover resources:
bash -c 'cd /opt/GTA/San-Andreas && wine ./gta_sa.exe | while read line; do if [[ $(echo $line | grep -i "leftover resource") ]]; then killall gta_sa.exe; exit; fi; done'
And I've got this output from gta_sa.exe before it hangs:
fixme:d3d:wined3d_device_uninit_3d Something's still holding the implicit swapchain.
fixme:d3d:wined3d_device_decref Device released with resources still bound, acceptable but unexpected.
fixme:d3d:wined3d_device_decref Leftover resource 0x539a5e8 with type WINED3D_RTYPE_TEXTURE_2D (0x2).
fixme:d3d:wined3d_device_decref Leftover resource 0x1b8ea8 with type WINED3D_RTYPE_TEXTURE_2D (0x2).
fixme:d3d:wined3d_device_decref Leftover resource 0x1b8cb0 with type WINED3D_RTYPE_TEXTURE_2D (0x2).
fixme:d3d:wined3d_device_decref Leftover resource 0x1b74b8 with type WINED3D_RTYPE_TEXTURE_2D (0x2).
However, it doesn't work, and the process still hangs. Why won't this command work?
Please note: this is not a question about Wine, it is about the script I made.
Best Answer
From the character of the
wine
's output I conclude that it is some kind of error message, therefore probably is redirected to stderr, not stdout. In that case pipe doesn't transmit the message and next command (while
) has nothing on its input. To overcome the problem you need to e.g. redirectwine
's stderr to stdout by adding2>&1
in front of the pipe|
.