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>
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