remove strange bloat dup2() usage, sync this code with mainstream login-utils, size...
author"Vladimir N. Oleynik" <dzo@simtreas.ru>
Tue, 13 Dec 2005 08:44:41 +0000 (08:44 -0000)
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>
Tue, 13 Dec 2005 08:44:41 +0000 (08:44 -0000)
loginutils/getty.c

index e8643ef93cca6d3b22e94ae93702bc3cad95dcd7..1cfbd6734746b4101b704b18fb4e05d90203f3b0 100644 (file)
@@ -528,12 +528,11 @@ static void open_tty(char *tty, struct termio *tp, int local)
 
                /* Open the tty as standard input. */
 
+               close(0);
                debug("open(2)\n");
                fd = open(tty, O_RDWR | O_NONBLOCK, 0);
-               if (dup2(fd, STDIN_FILENO) == -1)
+               if (fd != 0)
                        error("/dev/%s: cannot open as standard input: %m", tty);
-               close(fd);
-
        } else {
 
                /*