1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

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
This commit is contained in:
Timo Sirainen 2001-05-17 11:47:21 +00:00 committed by cras
parent 31499f142c
commit a88cd53ea5
2 changed files with 23 additions and 29 deletions

View File

@ -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) {

View File

@ -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