1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

core: quit WeeChat on ctrl-C (signal SIGINT) in headless mode

This commit is contained in:
Sébastien Helleu
2018-03-16 20:10:57 +01:00
parent 84f4e31425
commit 71999e17c6
3 changed files with 20 additions and 3 deletions
+4 -2
View File
@@ -88,7 +88,7 @@ time_t weechat_first_start_time = 0; /* start time (used by /uptime cmd) */
int weechat_upgrade_count = 0; /* number of /upgrade done */
struct timeval weechat_current_start_timeval; /* start time used to display */
/* duration of /upgrade */
int weechat_quit = 0; /* = 1 if quit request from user */
volatile sig_atomic_t weechat_quit = 0; /* = 1 if quit request from user */
volatile sig_atomic_t weechat_quit_signal = 0; /* signal received, */
/* WeeChat must quit */
char *weechat_home = NULL; /* home dir. (default: ~/.weechat) */
@@ -421,7 +421,9 @@ weechat_startup_message ()
{
if (weechat_headless)
{
string_fprintf (stdout, _("WeeChat is running in headless mode."));
string_fprintf (stdout,
_("WeeChat is running in headless mode "
"(Ctrl-C to quit)."));
string_fprintf (stdout, "\n");
}
+1 -1
View File
@@ -105,7 +105,7 @@ extern int weechat_first_start;
extern time_t weechat_first_start_time;
extern struct timeval weechat_current_start_timeval;
extern int weechat_upgrade_count;
extern int weechat_quit;
extern volatile sig_atomic_t weechat_quit;
extern volatile sig_atomic_t weechat_quit_signal;
extern char *weechat_home;
extern char *weechat_local_charset;
+15
View File
@@ -142,6 +142,16 @@ gui_main_get_password (const char **prompt, char *password, int size)
endwin ();
}
/*
* Callback for system signal SIGINT: quits WeeChat.
*/
void
gui_main_signal_sigint ()
{
weechat_quit = 1;
}
/*
* Initializes GUI.
*/
@@ -154,6 +164,11 @@ gui_main_init ()
struct t_gui_bar_window *ptr_bar_win;
char title[256];
#ifdef WEECHAT_HEADLESS
/* allow Ctrl-C to quit WeeChat in headless mode */
util_catch_signal (SIGINT, &gui_main_signal_sigint);
#endif /* WEECHAT_HEADLESS */
initscr ();
if (CONFIG_BOOLEAN(config_look_eat_newline_glitch))