From bda677c3d185ba6d0ce4f4c5019f0fac8e2dfbba Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 8 Jul 2020 10:05:25 +0800 Subject: [PATCH] dracut-kdump.sh: exit shell when machine reboot The following scenario is observed: kdump: kdump_pre script exited with non-zero status! [ 5.104841] systemd[1]: Shutting down. [ 5.122162] printk: systemd-shutdow: 27 output lines suppressed due to ratelimiting kdump: dump target is /dev/mapper/rhel_hpe--dl380pgen8--02--vm--12-root kdump: saving to /sysroot//var/crash/127.0.0.1-2020-06-27-03:55:01/ kdump: saving vmcore-dmesg.txt kdump: saving vmcore-dmesg.txt complete kdump: saving vmcore Checking for memory holes : [ 0.0 %] / Checking for memory holes : [100.0 %] | [ 5.516573] systemd-shutdown[1]: Syncing filesystems and block devices. [ 5.519515] systemd-shutdown[1]: Sending SIGTERM to remaining processes... It is caused by the following script if [ $? -ne 0 ]; then echo "kdump: kdump_pre script exited with non-zero status!" do_final_action fi When do_final_action runs, a systemd service is forked for reboot, then the subshell returns, and parent continues to execute. Place "exit 1" to stop executing and make kdump service failure. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-kdump.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b71278d..c74c4b7 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -251,6 +251,8 @@ do_kdump_pre if [ $? -ne 0 ]; then echo "kdump: kdump_pre script exited with non-zero status!" do_final_action + # During systemd service to reboot the machine, stop this shell script running + exit 1 fi make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' do_dump