]> spindle.queued.net Git - midori/commitdiff
Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully
authorAvan Anishchuk <matimatik@gmail.com>
Sat, 31 Oct 2009 03:46:23 +0000 (04:46 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 31 Oct 2009 03:49:57 +0000 (04:49 +0100)
midori/main.c
wscript

index 1e5be1ed431a26e92109030ec82ea0c88b56d7d9..f76e29a39934fc633e3342b8f53ee65c7c788657 100644 (file)
     #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 cdbbf8696c4b5845503650d0584177c90657d1de..fad14bdb9704c56b8f7dc352397570b96c0ae41b 100644 (file)
--- 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')