From owner-svn-src-all@FreeBSD.ORG Sun Jun 14 17:00:35 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E256D106566B; Sun, 14 Jun 2009 17:00:35 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D06388FC1B; Sun, 14 Jun 2009 17:00:35 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5EH0ZhR054847; Sun, 14 Jun 2009 17:00:35 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5EH0Zgv054846; Sun, 14 Jun 2009 17:00:35 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906141700.n5EH0Zgv054846@svn.freebsd.org> From: Ed Schouten Date: Sun, 14 Jun 2009 17:00:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194198 - head/sbin/init X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2009 17:00:36 -0000 Author: ed Date: Sun Jun 14 17:00:35 2009 New Revision: 194198 URL: http://svn.freebsd.org/changeset/base/194198 Log: Fix the staircase issue properly this time. Even though I thought this bug was somewhere in the TTY layer, it turns out init(8) doesn't make sure /dev/console is opened initially properly. I've added revoke() to two pieces of code: - death(): Apart from killing the gettys on shutdown, this doesn't guarantee the TTY to be closed immediately. - runshutdown(): Just like setctty(), we should revoke /dev/console. Applications like syslogd may have file descriptors to the console. Modified: head/sbin/init/init.c Modified: head/sbin/init/init.c ============================================================================== --- head/sbin/init/init.c Sun Jun 14 16:48:17 2009 (r194197) +++ head/sbin/init/init.c Sun Jun 14 17:00:35 2009 (r194198) @@ -1495,9 +1495,16 @@ death(void) /* NB: should send a message to the session logger to avoid blocking. */ logwtmp("~", "shutdown", ""); + /* + * Also revoke the TTY here. Because runshutdown() may reopen + * the TTY whose getty we're killing here, there is no guarantee + * runshutdown() will perform the initial open() call, causing + * the terminal attributes to be misconfigured. + */ for (sp = sessions; sp; sp = sp->se_next) { sp->se_flags |= SE_SHUTDOWN; kill(sp->se_process, SIGHUP); + revoke(sp->se_device); } /* Try to run the rc.shutdown script within a period of time */ @@ -1566,6 +1573,7 @@ runshutdown(void) sigaction(SIGTSTP, &sa, (struct sigaction *)0); sigaction(SIGHUP, &sa, (struct sigaction *)0); + revoke(_PATH_CONSOLE); if ((fd = open(_PATH_CONSOLE, O_RDWR)) == -1) warning("can't open %s: %m", _PATH_CONSOLE); else {