[Gambas-user] Saving settings on system shutdown

Charlie Ogier charlie at cogier.com
Mon Oct 4 15:50:59 CEST 2021



On 04/10/2021 11:04, Bruce Steers wrote:
>
>
> On Sun, 3 Oct 2021 at 15:46, bb <adamnt42 at gmail.com 
> <mailto:adamnt42 at gmail.com>> wrote:
>
>     On Sun, 2021-10-03 at 11:59 +0100, Bruce Steers wrote:
>     > I have a program that starts with my system and runs in the
>     > background.
>     >
>     > It has icons i can move and on exit it saves the positions.
>     >
>     > I have noticed if i do not exit the program but shutdown the
>     computer
>     > the
>     > settings do not save.
>     >
>     > Of course i could just save the settings on moving icons but i
>     > wondered if
>     > there is a recommended method to catch an application exit due to a
>     > shutdown?
>     > Does the system just kill the program?
>     >
>     > I guessed DBus would probably be the best alternative way but
>     > wouldn't hurt
>     > to ask the experts if there is already an easier way.
>     >
>     > Thanks for any advice :)
>     >
>     > BruceS
>     > ----[ http://gambaswiki.org/wiki/doc/netiquette
>     <http://gambaswiki.org/wiki/doc/netiquette> ]----
>     This is an "I think" answer.
>     IT it depends on the distro.
>     IT most shutdowns for sysvinit systems use /etc/rc0.d/ scripts one of
>     which (say "K02sendsigs") controls the ending of "all" processes in
>     some manner, e.g. by sending them a SIGxxx (usually? a SIGHUP) signal
>     and then possibly waiting until "them" exits (or if they dont, then
>     killing them).
>     IT I dont know how systemd does it but hopefully it involves a signals
>     based method as well.
>
>     So, IT you should implement signal handling for your program via
>     gb.signal, find out whether you can trap the shutdown SIG used and
>     then
>     do whatever you need.
>
>     Interested in the answer btw.
>
>     cheers
>     bruce
>
>
> Cheers folks
>
> Got no results yet.
> have tried catching various signals SIGQUIT SIGPWR SIGHUP
> Computer just shuts down, no activity from application.
>
> Benoit. what does the gambas runtime do with my app on a shutdown call?
> is it a non intercept-able method that just kills the app so any 
> attempt at catching would be a waste of time?
> Or is it completely unhandled?
>
> Thanks (to all who advise)
>
> BruceS

Hi Bruce,

Why not save any Settings changes as they occur, then it wont matter if 
the program is force closed on shutdown.

Charlie
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211004/446aef4a/attachment.htm>


More information about the User mailing list