SIGINT and SIGTERM handling

Andrew Sackville-West andrew at swclan.homelinux.org
Mon Mar 10 21:41:37 EDT 2008


Hey guys, 

I have occaision to use my gnucash files in multiple locations and
maintain multiple copies of the files all kept up-to-date by various
methods that aren't really important.

What is important is that I sometimes leave a file open at my main
machine but want to edit a copy of the file elsewhere. In order to
ensure my local copy is up-to-date and I don't end up with an
inconsistent state, I kill my running instance remotely and update my
files before editting. This works fine but leaves me with file locks
hanging around. 

Because of autosave, this really isn't a danger and in fact, there is
no need to keep the file lock hanging around in the case of TERM or
INT. In all likelyhood, the file is already saved and a properly
handled TERM or INT could just close the file and drop the locks and
exit nicely instead of dying outright. 

I would like to fix this by the following: 

Set a couple of signal handlers in gnucash-bin.c in the two
inner-main* functions. These signal handlers would catch both TERM and
INT and do one of two things:

     In the case of the book being in a saved state (I'm cueing off
     the gnc_file_new() code form gnc_file.c) close everything nicely
     and exit.

     In the case the book is not closed, save an emergency copy* of the
     file and then exit.

Any thoughts on this? ISTM a nicer way to handle this situation and
may be useful in the case of someone shutting down the system and not
realising that they have a gnucash file open in another workspace, for
example. 


A

* maybe some day we could check for these emergency copies and handle
  that situation on startup...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20080310/3d6ea770/attachment.bin 


More information about the gnucash-devel mailing list