From 6ee5808be791510ee549529218ebd9e61853a5ef Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Fri, 6 Apr 2012 13:06:01 +0000 Subject: [PATCH] Properly clear the O_NONBLOCK flag after opening the TTY. Though we should open the TTY with O_NONBLOCK to prevent rc(8) execution from potentially stalling, we must not forget to clear the flag later on, to prevent read(2) calls from failing later on. This prevented the shell pathname prompt from working properly. Reported by: kib --- sbin/init/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sbin/init/init.c b/sbin/init/init.c index a24371cbc235..8fd93bdfec56 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -572,9 +572,13 @@ open_console(void) { int fd; - /* Try to open /dev/console. */ + /* + * Try to open /dev/console. Open the device with O_NONBLOCK to + * prevent potential blocking on a carrier. + */ revoke(_PATH_CONSOLE); if ((fd = open(_PATH_CONSOLE, O_RDWR | O_NONBLOCK)) != -1) { + (void)fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); if (login_tty(fd) == 0) return; close(fd);