From a1c22adf5f7130c9e6f3bd6d23bcec9542575a27 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 6 Apr 2012 13:06:01 +0000 Subject: 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(-) (limited to 'sbin/init') diff --git a/sbin/init/init.c b/sbin/init/init.c index a24371c..8fd93bd 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); -- cgit v1.1