diff --git a/src/getty.c b/src/getty.c index c1cabc40..240a7e45 100644 --- a/src/getty.c +++ b/src/getty.c @@ -224,10 +224,15 @@ int getty(char *tty, speed_t speed, char *term, char *user) dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); + close(fd); if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0) warn("Failed TIOCSCTTY"); + /* Set up TTY, re-enabling ISIG et al. */ + stty(STDIN_FILENO, speed); + (void)write(STDOUT_FILENO, "\n", 1); + /* The getty process is responsible for the UTMP login record */ utmp_set_login(tty, NULL); if (!user) @@ -235,10 +240,6 @@ int getty(char *tty, speed_t speed, char *term, char *user) else strlcpy(name, user, sizeof(name)); - /* Set up TTY, re-enabling ISIG et al. */ - stty(fd, speed); - close(fd); - if (term && term[0]) setenv("TERM", term, 1);