Like for 'start' move the printing of the error message to the calling
function. This not only makes the code more consistent to 'start' but
also prevents 'kdumpctl restart' to call 'start' in case 'stop'
has
failed. This doesn't impact the case when 'kdumpctl restart' is run
without any crash kernel being loaded as kexec will still return success
in that case.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
---
kdumpctl | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 77ed584..3d3b9d4 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1090,15 +1090,9 @@ reload_fadump()
stop()
{
if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then
- stop_fadump
+ stop_fadump || return
else
- stop_kdump
- fi
-
- # shellcheck disable=SC2181
- if [[ $? != 0 ]]; then
- derror "Stopping kdump: [FAILED]"
- return 1
+ stop_kdump || return
fi
dinfo "Stopping kdump: [OK]"
@@ -1684,7 +1678,10 @@ main()
fi
;;
stop)
- stop
+ if ! stop; then
+ derror "Stopping kdump: [FAILED]"
+ exit 1
+ fi
;;
status)
EXIT_CODE=0
@@ -1705,7 +1702,10 @@ main()
reload
;;
restart)
- stop
+ if ! stop; then
+ derror "Stopping kdump: [FAILED]"
+ exit 1
+ fi
if ! start; then
derror "Starting kdump: [FAILED]"
exit 1
--
2.39.0