File sysstat-don-t-send-signal-to-init.patch of Package sysstat.4520
From c615fdc46370f93464d35866619f9a3e7c1a5d8a Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Sat, 18 Oct 2014 15:35:43 +0200
Subject: [PATCH] sadc: Don't send signal if parent process is already dead
If sar (parent of sadc) dies before sadc completes its job
then init will become sadc parent. Now if we pass SIGINT to
sadc, it will pass that to init process and result in system
reboot.
This patch check parent process before sending signal.
Test case:
Run sar_test script in shell prompt and press ctrl+C twice.
cat sar_test
while true; do /usr/local/bin/sar -n DEV 1 3; sleep 3; done
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
---
sadc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sadc.c b/sadc.c
index 55e76f5..4d737d0 100644
--- a/sadc.c
+++ b/sadc.c
@@ -238,6 +238,10 @@ void int_handler(int sig)
exit(1);
}
+ /* Don't send signal to init process!! */
+ if (getppid() == 1)
+ return;
+
/*
* When starting sar then pressing ctrl/c, SIGINT is received
* by sadc, not sar. So send SIGINT to sar so that average stats
--
1.8.5.6