From: Karel Zak Date: Thu, 12 Jul 2012 14:33:52 +0000 (+0200) Subject: login: close tty before vhangup() X-Git-Tag: v2.22-rc1~158 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e7035646eb85851171cc2e989bfa858a4f00cd4;p=thirdparty%2Futil-linux.git login: close tty before vhangup() Let's close all tty file descriptors before vhangup() call. References: https://lkml.org/lkml/2012/6/5/145 Signed-off-by: Karel Zak --- diff --git a/login-utils/login.c b/login-utils/login.c index fe13d8d1d4..c0cc00a667 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -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);