mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05: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:
parent
31499f142c
commit
a88cd53ea5
@ -35,9 +35,6 @@
|
|||||||
|
|
||||||
#include <signal.h>
|
#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_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);
|
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;
|
static ENTRY_REDIRECT_REC *redir;
|
||||||
|
|
||||||
char *cutbuffer;
|
char *cutbuffer;
|
||||||
static int readtag, sigint_count = 0;
|
static int readtag;
|
||||||
static time_t idle_time;
|
static time_t idle_time;
|
||||||
|
|
||||||
static void handle_key_redirect(int key)
|
static void handle_key_redirect(int key)
|
||||||
@ -121,12 +118,6 @@ void handle_key(int key)
|
|||||||
{
|
{
|
||||||
char str[3];
|
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);
|
idle_time = time(NULL);
|
||||||
|
|
||||||
if (redir != NULL && redir->flags & ENTRY_REDIRECT_FLAG_HOTKEY) {
|
if (redir != NULL && redir->flags & ENTRY_REDIRECT_FLAG_HOTKEY) {
|
||||||
|
@ -76,25 +76,32 @@ static void sig_winch(int p)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME: SIGINT != ^C .. any better way to make this work? */
|
|
||||||
void sigint_handler(int p)
|
|
||||||
{
|
|
||||||
ungetch(3);
|
|
||||||
readline();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void read_signals(void)
|
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;
|
const char *ignores;
|
||||||
|
struct sigaction act;
|
||||||
|
int n;
|
||||||
|
|
||||||
ignores = settings_get_str("ignore_signals");
|
ignores = settings_get_str("ignore_signals");
|
||||||
#ifndef WIN32
|
|
||||||
signal(SIGHUP, find_substr(ignores, "hup") ? SIG_IGN : SIG_DFL);
|
sigemptyset (&act.sa_mask);
|
||||||
signal(SIGQUIT, find_substr(ignores, "quit") ? SIG_IGN : SIG_DFL);
|
act.sa_flags = 0;
|
||||||
signal(SIGTERM, find_substr(ignores, "term") ? SIG_IGN : SIG_DFL);
|
|
||||||
signal(SIGALRM, find_substr(ignores, "alrm") ? SIG_IGN : SIG_DFL);
|
for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) {
|
||||||
signal(SIGUSR1, find_substr(ignores, "usr1") ? SIG_IGN : SIG_DFL);
|
act.sa_handler = find_substr(ignores, signames[n]) ?
|
||||||
signal(SIGUSR2, find_substr(ignores, "usr2") ? SIG_IGN : SIG_DFL);
|
SIG_IGN : SIG_DFL;
|
||||||
|
sigaction(signals[n], &act, NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,13 +132,9 @@ static int init_curses(void)
|
|||||||
if (COLS < MIN_SCREEN_WIDTH)
|
if (COLS < MIN_SCREEN_WIDTH)
|
||||||
COLS = MIN_SCREEN_WIDTH;
|
COLS = MIN_SCREEN_WIDTH;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef SIGWINCH
|
||||||
sigemptyset (&act.sa_mask);
|
sigemptyset (&act.sa_mask);
|
||||||
act.sa_flags = 0;
|
act.sa_flags = 0;
|
||||||
act.sa_handler = sigint_handler;
|
|
||||||
sigaction(SIGINT, &act, NULL);
|
|
||||||
#endif
|
|
||||||
#ifdef SIGWINCH
|
|
||||||
act.sa_handler = sig_winch;
|
act.sa_handler = sig_winch;
|
||||||
sigaction(SIGWINCH, &act, NULL);
|
sigaction(SIGWINCH, &act, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user