Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Apr 2012 13:06:01 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r233945 - head/sbin/init
Message-ID:  <201204061306.q36D611i009782@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Apr  6 13:06:01 2012
New Revision: 233945
URL: http://svn.freebsd.org/changeset/base/233945

Log:
  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

Modified:
  head/sbin/init/init.c

Modified: head/sbin/init/init.c
==============================================================================
--- head/sbin/init/init.c	Fri Apr  6 11:09:49 2012	(r233944)
+++ head/sbin/init/init.c	Fri Apr  6 13:06:01 2012	(r233945)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204061306.q36D611i009782>