[Xfce4-commits] <xfce4-appfinder:master> Quit the mainloop when receiving an exit signal.
Nick Schermer
noreply at xfce.org
Mon Dec 26 16:50:01 CET 2011
Updating branch refs/heads/master
to 40969cbff18d15f6f352f11e1ad9f696abfb7086 (commit)
from d92d85420c793a0fdcc49c0358efe6fe7f404fec (commit)
commit 40969cbff18d15f6f352f11e1ad9f696abfb7086
Author: Nick Schermer <nick at xfce.org>
Date: Mon Dec 26 16:44:24 2011 +0100
Quit the mainloop when receiving an exit signal.
src/main.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/main.c b/src/main.c
index 457d81c..1897461 100644
--- a/src/main.c
+++ b/src/main.c
@@ -300,6 +300,23 @@ appfinder_daemonize (void)
+static void
+appfinder_signal_handler (gint signum)
+{
+ static gboolean was_triggered = FALSE;
+
+ /* avoid recursing this handler */
+ if (was_triggered)
+ return;
+ was_triggered = TRUE;
+
+ APPFINDER_DEBUG ("received signal %s", g_strsignal (signum));
+
+ gtk_main_quit ();
+}
+
+
+
static DBusConnection *
appfinder_dbus_service (const gchar *startup_id)
{
@@ -396,6 +413,8 @@ main (gint argc, gchar **argv)
DBusConnection *dbus_connection = NULL;
const gchar *startup_id;
GSList *windows_destroy;
+ const gint signums[] = { SIGINT, SIGQUIT, SIGTERM, SIGABRT };
+ guint i;
/* set translation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -436,6 +455,10 @@ main (gint argc, gchar **argv)
if (opt_quit)
return appfinder_dbus_quit ();
+ /* setup signal handlers to properly quit the main loop */
+ for (i = 0; i < G_N_ELEMENTS (signums); i++)
+ signal (signums[i], appfinder_signal_handler);
+
/* if started with the xfrun4 executable, start in collapsed mode */
if (!opt_collapsed && strcmp (*argv, "xfrun4") == 0)
opt_collapsed = TRUE;
More information about the Xfce4-commits
mailing list