diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 7f74eb6999..7ff5758281 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -219,7 +219,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", [] { - if(quitES("/tmp/es-restart") != 0) + if(runRestartCommand() != 0) LOG(LogWarning) << "Restart terminated with non-zero result!"; }, "NO", nullptr)); }); @@ -241,7 +241,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES", [] { - if(quitES("/tmp/es-shutdown") != 0) + if(runShutdownCommand() != 0) LOG(LogWarning) << "Shutdown terminated with non-zero result!"; }, "NO", nullptr)); }); diff --git a/es-core/src/platform.cpp b/es-core/src/platform.cpp index 2e604af0f9..291ca72999 100644 --- a/es-core/src/platform.cpp +++ b/es-core/src/platform.cpp @@ -82,26 +82,35 @@ std::string getHomePath() int runShutdownCommand() { + int returnCode = 0; #if defined(WIN32) - return system("shutdown -s -t 0"); + returnCode = system("shutdown -s -t 0"); #elif defined(__linux__) sync(); - return reboot(RB_POWER_OFF); + returnCode = reboot(RB_POWER_OFF); #else - return system("sudo shutdown -h now"); + returnCode = system("sudo shutdown -h now"); #endif + + //Clean up the SDL + quitES("/tmp/es-shutdown"); + return returnCode; } int runRestartCommand() { + int returnCode = 0; #if defined(WIN32) - return system("shutdown -r -t 0"); + returnCode = system("shutdown -r -t 0"); #elif defined(__linux__) sync(); - return reboot(RB_AUTOBOOT); + returnCode = reboot(RB_AUTOBOOT); #else - return system("sudo shutdown -r now"); + returnCode = system("sudo shutdown -r now"); #endif + //Clean up the SDL + quitES("/tmp/es-restart"); + return returnCode; } int runSystemCommand(const std::string& cmd_utf8)