Skip to content

Commit

Permalink
When shutting down or rebooting keep trying alternate methods if the …
Browse files Browse the repository at this point in the history
…first ones fail.

The order is user specified command, Dbus then hard coded halt command. Fixes #9102.
(cherry picked from commit 4138b32)
  • Loading branch information
Paul Harrison committed Feb 13, 2011
1 parent 20929be commit ad3c81f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions mythtv/programs/mythfrontend/exitprompt.cpp
Expand Up @@ -12,6 +12,7 @@
#include "mythmainwindow.h"
#include "mythscreenstack.h"
#include "mythsystem.h"
#include "mythverbose.h"

void ExitPrompter::quit()
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ad3c81f

Please sign in to comment.