Follow-up to cf60cdd, make sure to disable ISIG before calling getty

Disable INTR, QUIT, SUSP, and DSUSP while handing over to getty.  It is
up to the getty process to allow ISIG again.

This patch is due to the differences in control line setup between ARM,
x86/x86_64, and most notably PPC.  PPC in particular seem to have ISIG
set by default from the kernel.

Without this patch pressing Ctrl-C before getty is started will lead to
Finit receiving SIGINT and defaulting to a reboot, as introduced in the
BusyBox init signal adoption in eeb59eb.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-23 11:57:58 +02:00
parent a36dafaa6c
commit 7970e45f45
+13
View File
@@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <termios.h>
#include <lite/lite.h>
#include "finit.h"
@@ -236,6 +237,18 @@ int exec_runtask(char *cmd, char *args[])
static void prepare_tty(char *tty, char *procname, int console)
{
struct termios term;
/*
* Disable INTR, QUIT, SUSP, and DSUSP while handing over to
* getty. It is up to the getty process to allow ISIG again.
*/
tcdrain(STDIN_FILENO);
if (!tcgetattr(STDIN_FILENO, &term)) {
term.c_lflag &= ~ISIG;
tcsetattr(STDIN_FILENO, TCSANOW, &term);
}
/* Reset signal handlers that were set by the parent process */
sig_unblock();
setsid();