From faf0c680b806d9561103feaefa1c8fbcac02c2eb Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 29 Oct 2017 12:14:04 +0100 Subject: [PATCH] getty: Disable ECHO, XON/OFF while waiting for initial Signed-off-by: Joachim Nilsson --- src/exec.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/exec.c b/src/exec.c index b776c281..fb2f7fb1 100644 --- a/src/exec.c +++ b/src/exec.c @@ -266,12 +266,22 @@ static void prepare_tty(char *tty, char *procname) static int activate_console(int noclear, int nowait) { + int ret = 0; + struct termios term; + if (!noclear) (void)write(STDERR_FILENO, "\e[r\e[H\e[J", 9); if (nowait) return 1; + /* Disable ECHO, XON/OFF while waiting for */ + if (!tcgetattr(STDIN_FILENO, &term)) { + term.c_iflag &= ~(IXON|IXOFF); + term.c_lflag &= ~ECHO; + tcsetattr(STDIN_FILENO, TCSANOW, &term); + } + while (!fexist(SYNC_SHUTDOWN)) { char c; static const char msg[] = "\nPlease press Enter to activate this console."; @@ -288,10 +298,18 @@ static int activate_console(int noclear, int nowait) if (fexist(SYNC_STOPPED)) continue; - return 1; + ret = 1; + break; } - return 0; + /* Restore ECHO, XON/OFF while waiting for */ + if (!tcgetattr(STDIN_FILENO, &term)) { + term.c_iflag |= IXON|IXOFF; + term.c_lflag |= ECHO; + tcsetattr(STDIN_FILENO, TCSANOW, &term); + } + + return ret; } pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait)