From 796701c854da4cdcf2c4cbc786c839e632754d84 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 31 Oct 2017 20:54:56 +0100 Subject: [PATCH] getty: Ignore SIGINT & C:o earlier Signed-off-by: Joachim Nilsson --- src/exec.c | 12 ++++++++++++ src/getty.c | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/exec.c b/src/exec.c index af4d6758..2f4d192c 100644 --- a/src/exec.c +++ b/src/exec.c @@ -236,6 +236,7 @@ int exec_runtask(char *cmd, char *args[]) static void prepare_tty(char *tty, speed_t speed, char *procname) { + struct sigaction sa; struct termios term; /* @@ -257,6 +258,17 @@ static void prepare_tty(char *tty, speed_t speed, char *procname) /* Reset signal handlers that were set by the parent process */ sig_unblock(); + + /* + * Ignore a few signals, needed to prevent Ctrl-C at login: + * prompt and to prevent QUIT from dumping core. + */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGQUIT, &sa, NULL); setsid(); /* Set INIT_PROCESS UTMP entry */ diff --git a/src/getty.c b/src/getty.c index e83a42c1..f05226b3 100644 --- a/src/getty.c +++ b/src/getty.c @@ -212,7 +212,6 @@ int getty(char *tty, speed_t speed, char *term, char *user) { int fd; char name[30]; - struct sigaction sa; /* Detach from initial controlling TTY */ vhangup(); @@ -228,17 +227,6 @@ int getty(char *tty, speed_t speed, char *term, char *user) if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0) warn("Failed TIOCSCTTY"); - /* - * Ignore a few signals, needed to prevent Ctrl-C at login: - * prompt and to prevent QUIT from dumping core. - */ - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sa.sa_handler = SIG_IGN; - sigaction(SIGHUP, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGQUIT, &sa, NULL); - /* The getty process is responsible for the UTMP login record */ utmp_set_login(tty, NULL); if (!user)