summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1997-06-28 08:18:29 +0000
committerpst <pst@FreeBSD.org>1997-06-28 08:18:29 +0000
commit489b7a4fe844901cd97a4c6ac90a05b5a0952445 (patch)
treecfa2e7986adf1a8ea1ec8e4025f4e58de3f4600e
parent4a9547432a88dd55a836d40499a08da09260348e (diff)
downloadFreeBSD-src-489b7a4fe844901cd97a4c6ac90a05b5a0952445.zip
FreeBSD-src-489b7a4fe844901cd97a4c6ac90a05b5a0952445.tar.gz
Attempt to open the device for reading before actually adding the device
to the session list. If the device comes back as unconfigured, just ignore that line in /etc/ttys. If someone HUP's init, we'll try again. This change stops getty's from hanging on vty and sio ports that don't exist, either due to LKM drivers not being loaded, or probes failing. Reviewed by: bde
-rw-r--r--sbin/init/init.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index ed2da13..6e9c9b4 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: init.c,v 1.17 1997/06/13 06:24:42 charnier Exp $
*/
#ifndef lint
@@ -935,6 +935,7 @@ new_session(sprev, session_index, typ)
register struct ttyent *typ;
{
register session_t *sp;
+ int fd;
if ((typ->ty_status & TTY_ON) == 0 ||
typ->ty_name == 0 ||
@@ -949,6 +950,18 @@ new_session(sprev, session_index, typ)
sp->se_device = malloc(sizeof(_PATH_DEV) + strlen(typ->ty_name));
(void) sprintf(sp->se_device, "%s%s", _PATH_DEV, typ->ty_name);
+ /*
+ * Attempt to open the device, if we get "device not configured"
+ * then don't add the device to the session list.
+ */
+ if ((fd = open(sp->se_device, O_RDONLY | O_NONBLOCK, 0)) < 0) {
+ if (errno == ENXIO) {
+ free_session(sp);
+ return (0);
+ }
+ } else
+ close(fd);
+
if (setupargv(sp, typ) == 0) {
free_session(sp);
return (0);
OpenPOWER on IntegriCloud