summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Harrison <pharrison@mythtv.org>2011-02-13 15:39:26 (GMT)
committer Paul Harrison <pharrison@mythtv.org>2011-02-13 15:43:17 (GMT)
commitad3c81f086aafc32477163d7b40117aefac55d76 (patch)
tree83634493667decd19b357c3aa8241836862ac6dd
parent20929be6a83b27a04c6489926baaa3b7ec312c98 (diff)
When shutting down or rebooting keep trying alternate methods if the first ones fail.
The order is user specified command, Dbus then hard coded halt command. Fixes #9102. (cherry picked from commit 4138b324fd7a8c7d9313859e54d4944c55e02519)
-rw-r--r--mythtv/programs/mythfrontend/exitprompt.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/mythtv/programs/mythfrontend/exitprompt.cpp b/mythtv/programs/mythfrontend/exitprompt.cpp
index dbcdc9d..c7c71a4 100644
--- a/mythtv/programs/mythfrontend/exitprompt.cpp
+++ b/mythtv/programs/mythfrontend/exitprompt.cpp
@@ -12,6 +12,7 @@
#include "mythmainwindow.h"
#include "mythscreenstack.h"
#include "mythsystem.h"
+#include "mythverbose.h"
void ExitPrompter::quit()
{
@@ -62,16 +63,18 @@ static bool DBusHalt(void)
void ExitPrompter::halt()
{
-
QString halt_cmd = gCoreContext->GetSetting("HaltCommand","");
+ int ret = -1;
+
if (!halt_cmd.isEmpty()) /* Use user specified command if it exists */
{
- myth_system(halt_cmd);
- } else if (!DBusHalt()) /* If supported, use DBus to shutdown */
- {
- myth_system("sudo /sbin/halt -p");
+ ret = myth_system(halt_cmd);
+ if (ret != 0)
+ VERBOSE(VB_IMPORTANT, "User defined HaltCommand failed, falling back to alternative methods.");
}
+ if (ret != 0 && !DBusHalt()) /* If supported, use DBus to shutdown */
+ myth_system("sudo /sbin/halt -p");
}
static bool DBusReboot(void)
@@ -118,16 +121,18 @@ static bool DBusReboot(void)
void ExitPrompter::reboot()
{
-
QString reboot_cmd = gCoreContext->GetSetting("RebootCommand","");
+ int ret = -1;
+
if (!reboot_cmd.isEmpty()) /* Use user specified command if it exists */
{
- myth_system(reboot_cmd);
- } else if (!DBusReboot()) /* If supported, use DBus to reboot */
- {
- myth_system("sudo /sbin/reboot");
+ ret = myth_system(reboot_cmd);
+ if (ret != 0)
+ VERBOSE(VB_IMPORTANT, "User defined RebootCommand failed, falling back to alternative methods.");
}
+ if (ret != 0 && !DBusReboot()) /* If supported, use DBus to reboot */
+ myth_system("sudo /sbin/reboot");
}
void ExitPrompter::handleExit()