From eaba08790e540b50199c66a8dfccdd29e237139f Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 28 Oct 2016 12:58:40 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.freebsd.org/base/stable/10@308036 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/init/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sbin/init/init.c b/sbin/init/init.c index af672a9ad..ba113c83a 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -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"); -- 2.45.0