From 489b7a4fe844901cd97a4c6ac90a05b5a0952445 Mon Sep 17 00:00:00 2001 From: pst Date: Sat, 28 Jun 1997 08:18:29 +0000 Subject: 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 --- sbin/init/init.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sbin') 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); -- cgit v1.1