Clear current line before starting built-in getty

When logging out from the shell, e.g. with Ctrl-D, artifacts from that
session may remain on the current line.  This patch makes sure to clear
up that line before issuing a newline and starting the built-in getty.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-01-06 19:37:00 +01:00
parent b4b9111b33
commit 397f67d03a
+3 -2
View File
@@ -211,8 +211,9 @@ static int do_login(char *name)
int getty(char *tty, speed_t speed, char *term, char *user)
{
int fd;
const char cln[] = "\r\e[2K\n";
char name[30];
int fd;
/* Detach from initial controlling TTY */
vhangup();
@@ -231,7 +232,7 @@ int getty(char *tty, speed_t speed, char *term, char *user)
/* Set up TTY, re-enabling ISIG et al. */
stty(STDIN_FILENO, speed);
(void)write(STDOUT_FILENO, "\n", 1);
(void)write(STDOUT_FILENO, cln, strlen(cln));
/* The getty process is responsible for the UTMP login record */
utmp_set_login(tty, NULL);