aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-05-22 10:48:51 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:18 +0800
commit2191c224c025580c15e78ca2cee6344cbe22ea42 (patch)
treef237cd1c39983306467cb75d5265df03b3f793d6
parent43e043c2c4c210a60d74727fe82189fe32f1a288 (diff)
downloadgsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar.gz
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar.bz2
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar.lz
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar.xz
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.tar.zst
gsoc2013-evolution-2191c224c025580c15e78ca2cee6344cbe22ea42.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;