Fix #84: Reset TTY w/ stty() before taking any pre-getty action

This patch moves the stty() function from getty.c to a separate file so
it can be called from exec.c as well.  The fix to #84 is simply to call
stty() in prepare_tty(), which is shared by run_getty() and run_getty2()
and called before "Please press Enter ...".

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-29 11:59:48 +01:00
parent b45c3d5cb8
commit 250e26f2f6
5 changed files with 79 additions and 39 deletions
+7 -2
View File
@@ -240,8 +240,13 @@ static void prepare_tty(char *tty, char *procname)
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.
* Reset to sane defaults in case of messup from prev. session
*/
stty(STDIN_FILENO, B38400);
/*
* Disable ISIG (INTR, QUIT, SUSP) before handing over to getty.
* It is up to the getty process to allow them again.
*/
tcdrain(STDIN_FILENO);
if (!tcgetattr(STDIN_FILENO, &term)) {