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) | |
download | busybox-w32-e206a4de4c700230f3dc9fdaa101c6f4432e1c27.tar.gz busybox-w32-e206a4de4c700230f3dc9fdaa101c6f4432e1c27.tar.bz2 busybox-w32-e206a4de4c700230f3dc9fdaa101c6f4432e1c27.zip |
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) | |||
556 | * In this case (setsid failed) we may still have ctty, | 556 | * In this case (setsid failed) we may still have ctty, |
557 | * and it may be different from tty we need to control! | 557 | * and it may be different from tty we need to control! |
558 | * If we still have ctty, on Linux ioctl(TIOCSCTTY) | 558 | * If we still have ctty, on Linux ioctl(TIOCSCTTY) |
559 | * (which we are going to call a bit later) always fails. | 559 | * (which we are going to use a bit later) always fails - |
560 | * Try to drop ctty now to prevent that. | 560 | * even if we try to take ctty which is already ours! |
561 | * Try to drop old ctty now to prevent that. | ||
562 | * Use O_NONBLOCK: old ctty may be a serial line. | ||
561 | */ | 563 | */ |
562 | fd = open("/dev/tty", O_RDWR); | 564 | fd = open("/dev/tty", O_RDWR | O_NONBLOCK); |
563 | if (fd >= 0) { | 565 | if (fd >= 0) { |
564 | ioctl(fd, TIOCNOTTY); | 566 | ioctl(fd, TIOCNOTTY); |
565 | close(fd); | 567 | close(fd); |