summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-04-26 10:53:48 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-04-26 10:53:48 +0200
commiteced0c78a54bbecc61f1717d33f64ee7d99804bb (patch)
tree0042d7995c06e23d0a6cb1fefa640a01e16af2a0
parentb84dafb5e57462c91df48456dfc5bb7c811e7a24 (diff)
getty: fix for NOCTTY killing us with SIGHUP
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--loginutils/getty.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index afb411b98..bbb5a96b4 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -561,8 +561,14 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
*/
fd = open("/dev/tty", O_RDWR | O_NONBLOCK);
if (fd >= 0) {
+ /* TIOCNOTTY sends SIGHUP to the foreground
+ * process group - which may include us!
+ * Make sure to not die on it:
+ */
+ sighandler_t old = signal(SIGHUP, SIG_IGN);
ioctl(fd, TIOCNOTTY);
close(fd);
+ signal(SIGHUP, old);
}
}