gtk3 - logout during g_application_hold()

Viewed 175

My gtk3 application can either run within a GUI or in daemon-mode. In order to realize daemon-mode, I use g_application_hold().

So far this works great, however as soon as I logout from my session while running the application in daemon mode, my system freezes for 8 seconds, until OS kills it. Like that my clean shutdown procedure is not executed. That only happens for the daemon, not while in GUI-mode.

Currently I solved the problem by hooking the SIGHUP signal, which can be used to realize a session logout:

static void
handle_hangup_signal (int signal)
{
  MyApplication     *application = my_application_get ();
  g_application_release (G_APPLICATION (application));
}
...
signal(SIGHUP, handle_hangup_signal);

This fixes my bug. No 8 second delay, my clean-shutdown is executed.

However I wonder if there is a more clean gtk3 solution? Is it fine to use g_application_hold(), or is there some better gtk3 way to launch something in daemon-mode ?

1 Answers
Related