Block a variety of signals which may afffect reboot(8), before killing

init(8), to avoid losing a race to them and dying before being able
to call reboot(2).

PR:		bin/64664
Submitted by:	maxim
Obtained from:	NetBSD
MFC after:	30 days
This commit is contained in:
Bruce M Simpson 2006-08-02 13:05:38 +00:00
parent 050ac26521
commit d8f7093860
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160916

View File

@ -151,8 +151,21 @@ main(int argc, char *argv[])
if (!nflag)
sync();
/* Ignore the SIGHUP we get when our parent shell dies. */
(void)signal(SIGHUP, SIG_IGN);
/*
* Ignore signals that we can get as a result of killing
* parents, group leaders, etc.
*/
(void)signal(SIGHUP, SIG_IGN);
(void)signal(SIGINT, SIG_IGN);
(void)signal(SIGQUIT, SIG_IGN);
(void)signal(SIGTERM, SIG_IGN);
(void)signal(SIGTSTP, SIG_IGN);
/*
* If we're running in a pipeline, we don't want to die
* after killing whatever we're writing to.
*/
(void)signal(SIGPIPE, SIG_IGN);
/* Just stop init -- if we fail, we'll restart it. */
if (kill(1, SIGTSTP) == -1)