I'm working on a small program that sits in the background and runs
several counters and timers:
https://wiki.gnome.org/SummerOfCode2013/Projects/DylanMccall_BreakTimer
When the user logs out, I want my application to save its current
state to a file, and then restore from that file when the user logs
back in. Most of this is implemented (with Vala), and I'm connecting
to the SIGINT, SIGTERM and SIGHUP signals to trigger a clean exit:
public int main(string[] args) {
application = new HelperApplication();
Posix.signal(Posix.SIGINT, sigint_cb);
Posix.signal(Posix.SIGTERM, sigint_cb);
Posix.signal(Posix.SIGHUP, sigint_cb);
int status = application.run(args);
return status;
}
void sigint_cb(int signal_number) {
application.quit();
}
(There is a bunch of code in application.quit that handles the state
saving stuff).
Everything is fine if I exit the program by sending it one of those
signals, of course. The problem I'm running into is gnome-session
seems to be more aggressive (is it sending SIGKILL?), so, when the
user logs out, my program doesn't get a chance to save its state.
I looked at Gtk.Application.inhibit(), but what I'm doing doesn't
really jive with what that does (and I'm a big fan of semantics), and
I'm still stuck trying to reliably catch when we're logging out.
So… is there a useful pattern for doing something like
Posix.signal(Posix.SIGINT, …), but for gnome-session?
Thanks!
--
Dylan
_______________________________________________
gnome-devel-list mailing list
gnome-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-devel-list