aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-05-22 10:48:51 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-22 10:48:51 +0800
commit82b7348f1964dca50519140e3cfc062baa2996ef (patch)
tree468b3b923305758bfb6a79697b1cf29d8f6110dd
parentd44105562d14887773419f8d07ce26be34073b9e (diff)
downloadgsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar.gz
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar.bz2
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar.lz
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar.xz
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.tar.zst
gsoc2013-evolution-82b7348f1964dca50519140e3cfc062baa2996ef.zip
Bug 650524 - Use g_unix_signal_add_watch_full() for SIGTERM
We can't call anything safely except write() inside a signal handler, g_unix_signal_add_watch_full() handles this for us nicely.
-rw-r--r--shell/main.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/shell/main.c b/shell/main.c
index cab5ab9717..e1b768187d 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -26,6 +26,12 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+#include <glib-unix.h>
+#endif
+#endif
+
#if HAVE_CLUTTER
#include <clutter-gtk/clutter-gtk.h>
#include <mx/mx.h>
@@ -264,38 +270,23 @@ idle_cb (gchar **uris)
return FALSE;
}
-#ifndef G_OS_WIN32
-
-static void
-term_signal (gint sig)
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+static gboolean
+handle_term_signal (gpointer data)
{
EShell *shell;
- g_return_if_fail (sig == SIGTERM);
-
g_print ("Received terminate signal...\n");
shell = e_shell_get_default ();
if (shell != NULL)
e_shell_quit (shell, E_SHELL_QUIT_OPTION);
-}
-
-static void
-setup_term_signal (void)
-{
- struct sigaction sa, osa;
-
- sigaction (SIGTERM, NULL, &osa);
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
- sa.sa_handler = term_signal;
- sigaction (SIGTERM, &sa, NULL);
+ return FALSE;
}
-
-#else
-#define setup_term_signal() (void)0
+#endif
#endif
static GOptionEntry entries[] = {
@@ -621,7 +612,13 @@ main (gint argc, gchar **argv)
gconf_client_set_bool (client, key, FALSE, NULL);
}
- setup_term_signal ();
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+ g_unix_signal_add_watch_full (
+ SIGTERM, G_PRIORITY_DEFAULT,
+ handle_term_signal, NULL, NULL);
+#endif
+#endif
if (evolution_debug_log) {
gint fd;