Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue 42, the OS will now restart and shutdown if emulationstat… #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions es-app/src/guis/GuiMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand All @@ -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));
});
Expand Down
21 changes: 15 additions & 6 deletions es-core/src/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down