Block SIGHUP before killing init(8), to avoid a race condition which may

kill the current process and hang the system when attempting reboot.

PR:		bin/64664
Reviewed by:	ssouhal, phk (historic)
MFC after:	30 days
This commit is contained in:
bms 2006-08-02 12:42:20 +00:00
parent 08d14c0219
commit 03b3f7bd6f

View File

@ -151,13 +151,13 @@ main(int argc, char *argv[])
if (!nflag)
sync();
/* Ignore the SIGHUP we get when our parent shell dies. */
(void)signal(SIGHUP, SIG_IGN);
/* Just stop init -- if we fail, we'll restart it. */
if (kill(1, SIGTSTP) == -1)
err(1, "SIGTSTP init");
/* Ignore the SIGHUP we get when our parent shell dies. */
(void)signal(SIGHUP, SIG_IGN);
/* Send a SIGTERM first, a chance to save the buffers. */
if (kill(-1, SIGTERM) == -1 && errno != ESRCH)
err(1, "SIGTERM processes");