I'd really like some help here.
Attached is a demo of a problem with LCL apps running when the Linux box powers down. It creates 6 extra, non-modal windows keeping track of them in an array. When the main window closes down, it iterates over that array, closing each. (And, possibly, doing something specific because it's app is closing).
However, logging this as it happens reveals two separate actions -
- Initially, one or more slave windows usually, somehow, get a close down signal. That is seen in the log in .FormCloseQuery() and .FormClose().
- Seven seconds later, a SIGTERM (ie #15) is received by the main window and each one, including any 'closed' in the above step, are nicely closed and freed.
It appears that the slave Windows 'closed' in stage 1 remain responsive, is perhaps set to not visible (or are disconnected from the XServer (or Wayland) in much the same was as xkill works). So, it is still usable but has told the world its not.
I can not find any way to determine where this first, bogus 'close' command comes from. Nor any way to tell the difference between it and eg a user initiated close.
And the app holds up the OS shutdown by that seven seconds. If the slave window's CloseAction is set to caFree the window would be gone before a proper shutdown can be performed. Extract from log file (hh:nn:ss.zzz) -
16:22:34.652 Starting Log
16:22:42.740 TMyForm.FormCloseQuery Form 1
16:22:42.740 TMyForm.FormCloseQuery Visible=True
16:22:42.740 TMyForm.FormClose Form 1
16:22:49.759 Signal received #15
16:22:49.860 TMyForm.FormCloseQuery Form 0
16:22:49.860 TMyForm.FormCloseQuery Visible=True
16:22:49.860 TMyForm.FormClose Form 0
16:22:49.860 TMyForm.FormDestroy Form 0
16:22:49.964 TMyForm.FormCloseQuery Form 1
16:22:49.964 TMyForm.FormCloseQuery Visible=False
16:22:49.964 TMyForm.FormClose Form 1
16:22:49.964 TMyForm.FormDestroy Form 1
16:22:50.071 TMyForm.FormCloseQuery Form 2
....
16:22:50.410 The FormMain is closed
16:22:50.410 Signal received #1
16:22:50.410 Igoring second signal #1Note that the app is first affected by the shutdown at 42.740, one of the slave windows is hidden. Then 7 seconds later, the MainForm gets the message via my HandleSig() method ! And in this case, Form 1 is now hidden (and would be gone if CloseAction=caFree).
How and why does the slave window get this close signal before FormMain ?
If I send the app a SIGTERM with the kill command, no problems, it all works as it should. The issue is at shutdown where, I believe, System V or SystemD will send a SIGTERM in exactly the same way !
The attached project, should be compiled, then run (perhaps outside the IDE) and the computer told to restart. Find the log in $HOME and some demo text, written as each Window shuts down, in $HOME/junk/.
Any insight would be greatly appreciated !
Davo