From 7970e45f45d83507f0858fd3a38a2febaa7824b3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 23 Oct 2017 11:57:58 +0200 Subject: [PATCH] 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 --- src/exec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/exec.c b/src/exec.c index 201745cc..0202e2cf 100644 --- a/src/exec.c +++ b/src/exec.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #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();