getty: Ignore SIGINT & C:o earlier

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-31 20:54:56 +01:00
parent ab760aa3ff
commit 796701c854
2 changed files with 12 additions and 12 deletions
+12
View File
@@ -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 */
-12
View File
@@ -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)