diff options
author | B Stack <bgstack15@gmail.com> | 2021-02-02 21:49:34 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2021-02-02 21:49:34 +0000 |
commit | 26b8bd6eb07b78adad36049e03494a2931b231af (patch) | |
tree | 4d7c950512836f473a6a8cbb521c61e800db6584 /zen/shutdown.cpp | |
parent | Merge branch '11.5' into 'master' (diff) | |
parent | add upstream 11.6 (diff) | |
download | FreeFileSync-11.6.tar.gz FreeFileSync-11.6.tar.bz2 FreeFileSync-11.6.zip |
Merge branch '11.6' into 'master'11.6
add upstream 11.6
See merge request opensource-tracking/FreeFileSync!30
Diffstat (limited to 'zen/shutdown.cpp')
-rw-r--r-- | zen/shutdown.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
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 <zen/shell_execute.h> + #include <zen/process_exec.h> 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<std::wstring>(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<std::wstring>(output)); } catch (const SysError& e) { throw FileError(_("Unable to shut down the system."), e.toString()); } |