diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index b6fceb89..bc3429d8 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -35,9 +35,6 @@ #include -#undef CTRL -#define CTRL(x) ((x) & 0x1f) /* Ctrl+x */ - typedef void (*ENTRY_REDIRECT_KEY_FUNC) (int key, void *data, SERVER_REC *server, WI_ITEM_REC *item); typedef void (*ENTRY_REDIRECT_ENTRY_FUNC) (const char *line, void *data, SERVER_REC *server, WI_ITEM_REC *item); @@ -51,7 +48,7 @@ static KEYBOARD_REC *keyboard; static ENTRY_REDIRECT_REC *redir; char *cutbuffer; -static int readtag, sigint_count = 0; +static int readtag; static time_t idle_time; static void handle_key_redirect(int key) @@ -121,12 +118,6 @@ void handle_key(int key) { char str[3]; - /* Quit if we get 5 CTRL-C's in a row. */ - if (key != CTRL('c')) - sigint_count = 0; - else if (++sigint_count >= 5) - raise(SIGTERM); - idle_time = time(NULL); if (redir != NULL && redir->flags & ENTRY_REDIRECT_FLAG_HOTKEY) { diff --git a/src/fe-text/screen.c b/src/fe-text/screen.c index 4f07cfa5..5378b5c9 100644 --- a/src/fe-text/screen.c +++ b/src/fe-text/screen.c @@ -76,25 +76,32 @@ static void sig_winch(int p) } #endif -/* FIXME: SIGINT != ^C .. any better way to make this work? */ -void sigint_handler(int p) -{ - ungetch(3); - readline(); -} - static void read_signals(void) { +#ifndef WIN32 + int signals[] = { + SIGHUP, SIGINT, SIGQUIT, SIGTERM, + SIGALRM, SIGUSR1, SIGUSR2 + }; + char *signames[] = { + "hup", "int", "quit", "term", + "alrm", "usr1", "usr2" + }; + const char *ignores; + struct sigaction act; + int n; ignores = settings_get_str("ignore_signals"); -#ifndef WIN32 - signal(SIGHUP, find_substr(ignores, "hup") ? SIG_IGN : SIG_DFL); - signal(SIGQUIT, find_substr(ignores, "quit") ? SIG_IGN : SIG_DFL); - signal(SIGTERM, find_substr(ignores, "term") ? SIG_IGN : SIG_DFL); - signal(SIGALRM, find_substr(ignores, "alrm") ? SIG_IGN : SIG_DFL); - signal(SIGUSR1, find_substr(ignores, "usr1") ? SIG_IGN : SIG_DFL); - signal(SIGUSR2, find_substr(ignores, "usr2") ? SIG_IGN : SIG_DFL); + + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + + for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) { + act.sa_handler = find_substr(ignores, signames[n]) ? + SIG_IGN : SIG_DFL; + sigaction(signals[n], &act, NULL); + } #endif } @@ -125,13 +132,9 @@ static int init_curses(void) if (COLS < MIN_SCREEN_WIDTH) COLS = MIN_SCREEN_WIDTH; -#ifndef WIN32 +#ifdef SIGWINCH sigemptyset (&act.sa_mask); act.sa_flags = 0; - act.sa_handler = sigint_handler; - sigaction(SIGINT, &act, NULL); -#endif -#ifdef SIGWINCH act.sa_handler = sig_winch; sigaction(SIGWINCH, &act, NULL); #endif