From: Avan Anishchuk Date: Sat, 31 Oct 2009 03:46:23 +0000 (+0100) Subject: Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1133bc44490a16e455f000d2b49ca61b4d0c4386;p=midori Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully --- diff --git a/midori/main.c b/midori/main.c index 1e5be1ed..f76e29a3 100644 --- a/midori/main.c +++ b/midori/main.c @@ -54,6 +54,10 @@ #include #endif +#ifdef HAVE_SIGNAL_H + #include +#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 cdbbf869..fad14bdb 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')