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:
Bruce M Simpson 2006-08-02 12:42:20 +00:00
parent 7383472304
commit b08d1553f4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160914

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");