]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: close tty before vhangup()
authorKarel Zak <kzak@redhat.com>
Thu, 12 Jul 2012 14:33:52 +0000 (16:33 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 12 Jul 2012 14:35:01 +0000 (16:35 +0200)
Let's close all tty file descriptors before vhangup() call.

References: https://lkml.org/lkml/2012/6/5/145
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index fe13d8d1d470e3be9f384dfe64eabb5ea87aa148..c0cc00a667f3673eeb21a356d93f4030bf262c5b 100644 (file)
@@ -409,6 +409,14 @@ static void init_tty(struct login_context *cxt)
        /* Kill processes left on this tty */
        tcsetattr(0, TCSAFLUSH, &ttt);
 
+       /*
+        * Let's close file decriptors before vhangup
+        * https://lkml.org/lkml/2012/6/5/145
+        */
+       close(STDIN_FILENO);
+       close(STDOUT_FILENO);
+       close(STDERR_FILENO);
+
        signal(SIGHUP, SIG_IGN);        /* so vhangup() wont kill us */
        vhangup();
        signal(SIGHUP, SIG_DFL);