Discussion:
Detecting application termination
Bogdan Cristea
2011-05-26 20:55:01 UTC
Permalink
Hi

I am developing an application for MeeGo tablet. In order to save
current setting when the application finishes I have overloaded the
closeEvent slot method. This approach seems to work when the
application is properly closed (i.e. using the close() slot or by
clicking the close button from the main window frame), but when I
choose to stop the entire tablet (running MeeGo) by pushing the power
off button (confirmation from MeeGo OS) nothing is saved. Could you
advise on this issue and on how to capture the close event regardless
of the termination method ?

regards
--
Bogdan Cristea
Andy Ross
2011-05-26 21:54:50 UTC
Permalink
Post by Bogdan Cristea
Could you
advise on this issue and on how to capture the close event regardless
of the termination method ?
Shutdown will deliver SIGTERM, which you can catch. If all you need
to do is disk I/O, this might be enough. But if your shutdown
handling needs interaction with other processes, you'll have trouble
because they're getting the same signal simultaneously.

More broadly, you really can't handle this cleanly. SIGKILL is
uncatchable, as is hardware failure, bugs in your own code, the OOM
killer, etc... If you have critical state you don't want to lose,
keep it on persistent storage and not in memory.

Andy

Continue reading on narkive:
Loading...