diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-10-22 08:19:42 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-10-22 08:19:42 +0200 |
commit | e206a4de4c700230f3dc9fdaa101c6f4432e1c27 (patch) | |
tree | b4f990449b06bca978bb1955b69620f7204fca26 | |
parent | a241069004717c6bef0a4abdf515c0ed1b9304c9 (diff) |
getty: add O_NONBLOCK to open which is used to drop ctty
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | loginutils/getty.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c index 230846008..3496f0284 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c @@ -556,10 +556,12 @@ int getty_main(int argc UNUSED_PARAM, char **argv) * In this case (setsid failed) we may still have ctty, * and it may be different from tty we need to control! * If we still have ctty, on Linux ioctl(TIOCSCTTY) - * (which we are going to call a bit later) always fails. - * Try to drop ctty now to prevent that. + * (which we are going to use a bit later) always fails - + * even if we try to take ctty which is already ours! + * Try to drop old ctty now to prevent that. + * Use O_NONBLOCK: old ctty may be a serial line. */ - fd = open("/dev/tty", O_RDWR); + fd = open("/dev/tty", O_RDWR | O_NONBLOCK); if (fd >= 0) { ioctl(fd, TIOCNOTTY); close(fd); |