From dff52e4261b762fbf7dd69b79b071693ebcf36c9 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 21 Jun 2016 19:24:10 +0100 Subject: [PATCH] Correct exit status checks (status 0 returned by wait() doesn't have to mean "exited cleanly with 0 exit status", though it probably does on most real systems). --- src/service.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/service.cc b/src/service.cc index fef4c13..2c11965 100644 --- a/src/service.cc +++ b/src/service.cc @@ -154,7 +154,7 @@ void ServiceRecord::handle_exit_status() noexcept // (BGPROCESS only) doing_recovery = false; bool need_stop = false; - if (exit_status != 0) { + if ((did_exit && WEXITSTATUS(exit_status) != 0) || was_signalled) { need_stop = true; } else { @@ -179,7 +179,7 @@ void ServiceRecord::handle_exit_status() noexcept if (service_type == ServiceType::PROCESS || service_type == ServiceType::BGPROCESS) { if (service_state == ServiceState::STARTING) { // (only applies to BGPROCESS) - if (exit_status == 0) { + if (did_exit && WEXITSTATUS(exit_status) == 0) { started(); } else { @@ -207,7 +207,7 @@ void ServiceRecord::handle_exit_status() noexcept } else { // SCRIPTED if (service_state == ServiceState::STOPPING) { - if (exit_status == 0) { + if (did_exit && WEXITSTATUS(exit_status) == 0) { stopped(); } else { -- 2.25.1