Catch SIGHUP, SIGINT, SIGTERM and SIGQUIT and quit peacefully
This commit is contained in:
parent
3efbc1b462
commit
1133bc4449
2 changed files with 25 additions and 0 deletions
|
@ -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;
|
||||
|
|
1
wscript
1
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')
|
||||
|
|
Loading…
Reference in a new issue