From 83527efebc74c906aa6e7ed3205703db48002619 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Thu, 18 May 2017 16:54:29 -0500 Subject: Ensure softpoweroff application returns non-zero rc on fails This will ensure we follow the OnFailure= behavior defined within the shutdown target and properly power the system off on fails Change-Id: I4367602741ec06f32e5a39a21fccc914739fdda6 Signed-off-by: Andrew Geissler --- softoff/mainapp.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'softoff') diff --git a/softoff/mainapp.cpp b/softoff/mainapp.cpp index 0bfb067..7cf0eb7 100644 --- a/softoff/mainapp.cpp +++ b/softoff/mainapp.cpp @@ -21,6 +21,8 @@ #include "config.h" #include "timer.hpp" +// Return -1 on any errors to ensure we follow the calling targets OnFailure= +// path int main(int argc, char** argv) { using namespace phosphor::logging; @@ -34,14 +36,13 @@ int main(int argc, char** argv) // Add systemd object manager. sdbusplus::server::manager::manager(bus, SOFTOFF_OBJPATH); - // sd_event object. StateManager wants that this applicatin return '0' - // always. + // sd_event object auto r = sd_event_default(&events); if (r < 0) { log("Failure to create sd_event handler", entry("ERROR=%s", strerror(-r))); - return 0; + return -1; } // Attach the bus to sd_event to service user requests @@ -65,7 +66,7 @@ int main(int argc, char** argv) { log("Failure in processing request", entry("ERROR=%s", strerror(-r))); - break; + return -1; } } @@ -78,6 +79,7 @@ int main(int argc, char** argv) sdbusplus::xyz::openbmc_project::State::Host::Error::SoftOffTimeout; using errorMetadata = xyz::openbmc_project::State::Host::SoftOffTimeout; report(prev_entry()); + return -1; } // Cleanup the event handler -- cgit v1.2.1