[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] less: open new tty fd in non-blocking mode
From:       Aaro Koskinen <aaro.koskinen () iki ! fi>
Date:       2016-04-28 21:22:24
Message-ID: 1461878544-11876-1-git-send-email-aaro.koskinen () iki ! fi
[Download RAW message or body]

Open new tty fd in non-blocking mode, instead of first opening it
and then changing to non-blocking.

This will avoid the issue with serial console login, where less
seems to block forever waiting for carrier change when re-opening
the serial console.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 miscutils/less.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/miscutils/less.c b/miscutils/less.c
index c003b8d..2c56eb3 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1790,18 +1790,17 @@ int less_main(int argc, char **argv)
 	 */
 	tty_name = xmalloc_ttyname(STDOUT_FILENO);
 	if (tty_name) {
-		tty_fd = open(tty_name, O_RDONLY);
+		tty_fd = open(tty_name, O_RDONLY | O_NONBLOCK);
 		free(tty_name);
 		if (tty_fd < 0)
 			goto try_ctty;
 	} else {
 		/* Try controlling tty */
  try_ctty:
-		tty_fd = open(CURRENT_TTY, O_RDONLY);
+		tty_fd = open(CURRENT_TTY, O_RDONLY | O_NONBLOCK);
 		if (tty_fd < 0)
 			return bb_cat(argv);
 	}
-	ndelay_on(tty_fd);
 	kbd_fd = tty_fd; /* save in a global */
 
 	tcgetattr(kbd_fd, &term_orig);
-- 
2.7.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic