From d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8 Mon Sep 17 00:00:00 2001 From: B Stack Date: Tue, 2 Feb 2021 11:44:31 -0500 Subject: add upstream 11.6 --- zen/shutdown.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'zen/shutdown.cpp') diff --git a/zen/shutdown.cpp b/zen/shutdown.cpp index 8e8456df..f46caf6b 100644 --- a/zen/shutdown.cpp +++ b/zen/shutdown.cpp @@ -5,7 +5,7 @@ // ***************************************************************************** #include "shutdown.h" - #include + #include using namespace zen; @@ -19,9 +19,10 @@ void zen::shutdownSystem() //throw FileError { //https://linux.die.net/man/2/reboot => needs admin rights! //"systemctl" should work without admin rights: - const auto& [exitCode, output] = consoleExecute("systemctl poweroff", std::nullopt /*timeoutMs*/); //throw SysError, (SysErrorTimeOut) - if (!trimCpy(output).empty()) //see comment in suspendSystem() - throw SysError(output); + auto [exitCode, output] = consoleExecute("systemctl poweroff", std::nullopt /*timeoutMs*/); //throw SysError, (SysErrorTimeOut) + trim(output); + if (!output.empty()) //see comment in suspendSystem() + throw SysError(utfTo(output)); } catch (const SysError& e) { throw FileError(_("Unable to shut down the system."), e.toString()); } @@ -33,10 +34,11 @@ void zen::suspendSystem() //throw FileError try { //"systemctl" should work without admin rights: - const auto& [exitCode, output] = consoleExecute("systemctl suspend", std::nullopt /*timeoutMs*/); //throw SysError, (SysErrorTimeOut) + auto [exitCode, output] = consoleExecute("systemctl suspend", std::nullopt /*timeoutMs*/); //throw SysError, (SysErrorTimeOut) + trim(output); //why does "systemctl suspend" return exit code 1 despite apparent success!?? - if (!trimCpy(output).empty()) //at least we can assume "no output" on success - throw SysError(output); + if (!output.empty()) //at least we can assume "no output" on success + throw SysError(utfTo(output)); } catch (const SysError& e) { throw FileError(_("Unable to shut down the system."), e.toString()); } -- cgit