summaryrefslogtreecommitdiff
path: root/zen/shutdown.cpp
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-02-02 11:44:31 -0500
committerB Stack <bgstack15@gmail.com>2021-02-02 11:44:31 -0500
commitd299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8 (patch)
tree4d7c950512836f473a6a8cbb521c61e800db6584 /zen/shutdown.cpp
parentMerge branch '11.5' into 'master' (diff)
downloadFreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.gz
FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.bz2
FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.zip
add upstream 11.6
Diffstat (limited to 'zen/shutdown.cpp')
-rw-r--r--zen/shutdown.cpp16
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()); }
bgstack15