From 87adc023e9e85f57330a25cc1a61f1f8a4ca4c29 Mon Sep 17 00:00:00 2001 From: bms Date: Wed, 2 Aug 2006 13:05:38 +0000 Subject: 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 --- sbin/reboot/reboot.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sbin') diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 29790b4..de40307 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -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) -- cgit v1.1