summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2006-08-02 13:05:38 +0000
committerbms <bms@FreeBSD.org>2006-08-02 13:05:38 +0000
commit87adc023e9e85f57330a25cc1a61f1f8a4ca4c29 (patch)
tree5f143c4f83e84645ad25a5f33deb1c7f31b95aab
parent8db4b3b58684bef22999c01196deeeb4a5dd5714 (diff)
downloadFreeBSD-src-87adc023e9e85f57330a25cc1a61f1f8a4ca4c29.zip
FreeBSD-src-87adc023e9e85f57330a25cc1a61f1f8a4ca4c29.tar.gz
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
-rw-r--r--sbin/reboot/reboot.c17
1 files changed, 15 insertions, 2 deletions
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)
OpenPOWER on IntegriCloud