[Xfce4-commits] <midori:master> Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully
Christian Dywan
noreply at xfce.org
Sat Oct 31 05:06:02 CET 2009
Updating branch refs/heads/master
to 1133bc44490a16e455f000d2b49ca61b4d0c4386 (commit)
from 3efbc1b4628c1b0b6512e24eb2fe19e02e6dfa17 (commit)
commit 1133bc44490a16e455f000d2b49ca61b4d0c4386
Author: Avan Anishchuk <matimatik at gmail.com>
Date: Sat Oct 31 04:46:23 2009 +0100
Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully
midori/main.c | 24 ++++++++++++++++++++++++
wscript | 1 +
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index 1e5be1e..f76e29a 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -54,6 +54,10 @@
#include <libosso.h>
#endif
+#ifdef HAVE_SIGNAL_H
+ #include <signal.h>
+#endif
+
#define MIDORI_HISTORY_ERROR g_quark_from_string("MIDORI_HISTORY_ERROR")
typedef enum
@@ -1576,6 +1580,19 @@ midori_remove_config_file (gint clear_prefs,
}
}
+#ifdef HAVE_SIGNAL_H
+static void
+signal_handler (int signal_id)
+{
+ if (signal_id == SIGHUP || signal_id == SIGINT
+ || signal_id == SIGTERM || signal_id == SIGQUIT)
+ {
+ midori_app_quit_cb (NULL);
+ gtk_main_quit ();
+ }
+}
+#endif
+
int
main (int argc,
char** argv)
@@ -1651,6 +1668,13 @@ main (int argc,
textdomain (GETTEXT_PACKAGE);
#endif
+ #ifdef HAVE_SIGNAL_H
+ signal (SIGHUP, &signal_handler);
+ signal (SIGINT, &signal_handler);
+ signal (SIGTERM, &signal_handler);
+ signal (SIGQUIT, &signal_handler);
+ #endif
+
/* Parse cli options */
webapp = NULL;
config = NULL;
diff --git a/wscript b/wscript
index cdbbf86..fad14bd 100644
--- a/wscript
+++ b/wscript
@@ -234,6 +234,7 @@ def configure (conf):
conf.env['docs'] = option_enabled ('docs')
conf.check (header_name='unistd.h')
+ conf.check (header_name='signal.h')
if not conf.env['HAVE_UNIQUE']:
if Options.platform == 'win32':
conf.check (lib='ws2_32')
More information about the Xfce4-commits
mailing list