From: Davin McCall Date: Tue, 21 Jun 2016 18:24:10 +0000 (+0100) Subject: Correct exit status checks (status 0 returned by wait() doesn't have to mean X-Git-Tag: v0.04~22 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dff52e4261b762fbf7dd69b79b071693ebcf36c9;p=oweals%2Fdinit.git 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). --- 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 {