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. Interrupted sleep(3) is followed by _exit(), which might cause 'Going nowhere without my init' panic if init(8) exits before the reboot(2) really started, or before SIGTSTP stopped init(8) (both events are initiated by the parallel reboot(8) operation). I do not see other calls to sleep(STALL_TIMEOUT) as having the same disasterous consequences and kept them as is until the similar change is proven required. Reported and tested by: Andy Farkas <chuzzwassa@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 3 weeks
This commit is contained in:
parent
6b647a7ab8
commit
c7d05abb4c
@ -870,6 +870,7 @@ single_user(void)
|
|||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
const char *shell;
|
const char *shell;
|
||||||
char *argv[2];
|
char *argv[2];
|
||||||
|
struct timeval tv, tn;
|
||||||
#ifdef SECURE
|
#ifdef SECURE
|
||||||
struct ttyent *typ;
|
struct ttyent *typ;
|
||||||
struct passwd *pp;
|
struct passwd *pp;
|
||||||
@ -1002,7 +1003,14 @@ single_user(void)
|
|||||||
* reboot(8) killed shell?
|
* reboot(8) killed shell?
|
||||||
*/
|
*/
|
||||||
warning("single user shell terminated.");
|
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);
|
_exit(0);
|
||||||
} else {
|
} else {
|
||||||
warning("single user shell terminated, restarting");
|
warning("single user shell terminated, restarting");
|
||||||
|
Loading…
Reference in New Issue
Block a user