diff options
author | Timo Sirainen <cras@irssi.org> | 2001-05-17 11:47:21 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-05-17 11:47:21 +0000 |
commit | a88cd53ea50e3051e9def47a568ad1a7b22dd3a8 (patch) | |
tree | cfe17083906ae0c391529916866b13c8fa158f57 /src | |
parent | 31499f142cd52dc4805865706ddb863d10e8aa45 (diff) | |
download | irssi-a88cd53ea50e3051e9def47a568ad1a7b22dd3a8.zip |
raw() mode also disabled SIGINT == ^C, so remove the 5x^C = SIGTERM.
Also use sigaction() instead of signal() with /SET ignore_signals.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1500 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-text/gui-readline.c | 11 | ||||
-rw-r--r-- | src/fe-text/screen.c | 41 |
2 files changed, 23 insertions, 29 deletions
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 <signal.h> -#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 |