[Lazarus] Finding out how a program's being terminated
Sven Barth
pascaldragon at googlemail.com
Sat Feb 16 09:29:30 CET 2013
On 16.02.2013 09:22, Mark Morgan Lloyd wrote:
> On unix (Linux, Solaris etc.) is it possible to determine how a program
> written using Lazarus is being terminated? Specifically, is there any
> different behaviour when a kill signal arrives from a routine term
> signal, and is a title-bar close button simply a term signal?
SIGTERM can be caught and handled by application using a signal handler,
so it can do some cleanup or even ignore the signal completely.
SIGKILL can not be caught and will directly kill the process without any
chance for further progressing.
And a title bar close button does normally invoke a event of the used
GUI toolkit (in case of Windows it would be the message "WM_CLOSE", I
don't know the event names of GTK and Qt :) ) and not send a SIGTERM.
>
> I'm trying to think ahead and plan for what a bunch of related (but not
> necessarily tightly-coupled) programs do if there's e.g. a UPS shutdown
> notification which sends a kill signal. Specifically, if there's a
> routine term it is probably appropriate to save the current window
> sizes etc. while if there's a kill because the UPS is trying to shut
> everything down fast it's probably safest to assume that there's a risk
> of multiple programs trying to access common files simultaneously.
>
If there is a SIGKILL you can't do anything in your program and you
won't be notified that you even got that signal.
Regards,
Sven
More information about the Lazarus
mailing list