Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2016 12:58:40 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r308036 - stable/10/sbin/init
Message-ID:  <201610281258.u9SCweB5035556@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Oct 28 12:58:40 2016
New Revision: 308036
URL: https://svnweb.freebsd.org/changeset/base/308036

Log:
  MFC r306807:
  When making a pause after detecting hard kill of the single-user
  shell, ensure that we do sleep for at least the specified time, in
  presence of signals.

Modified:
  stable/10/sbin/init/init.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/init/init.c
==============================================================================
--- stable/10/sbin/init/init.c	Fri Oct 28 12:56:27 2016	(r308035)
+++ stable/10/sbin/init/init.c	Fri Oct 28 12:58:40 2016	(r308036)
@@ -876,6 +876,7 @@ single_user(void)
 	sigset_t mask;
 	const char *shell;
 	char *argv[2];
+	struct timeval tv, tn;
 #ifdef SECURE
 	struct ttyent *typ;
 	struct passwd *pp;
@@ -1008,7 +1009,14 @@ single_user(void)
 			 *  reboot(8) killed shell?
 			 */
 			warning("single user shell terminated.");
-			sleep(STALL_TIMEOUT);
+			gettimeofday(&tv, NULL);
+			tn = tv;
+			tv.tv_sec += STALL_TIMEOUT;
+			while (tv.tv_sec > tn.tv_sec || (tv.tv_sec ==
+			    tn.tv_sec && tv.tv_usec > tn.tv_usec)) {
+				sleep(1);
+				gettimeofday(&tn, NULL);
+			}
 			_exit(0);
 		} else {
 			warning("single user shell terminated, restarting");



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