summaryrefslogtreecommitdiff
path: root/zen/shutdown.cpp
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-01-15 08:16:08 -0500
committerB Stack <bgstack15@gmail.com>2019-01-15 08:16:08 -0500
commit7c855d11f23dc03d64a0099473a95402f3175280 (patch)
tree41b8a3085df4de883f2993773b138f1436e041a4 /zen/shutdown.cpp
parentMerge branch '10.7' into 'master' (diff)
downloadFreeFileSync-7c855d11f23dc03d64a0099473a95402f3175280.tar.gz
FreeFileSync-7c855d11f23dc03d64a0099473a95402f3175280.tar.bz2
FreeFileSync-7c855d11f23dc03d64a0099473a95402f3175280.zip
10.8
Diffstat (limited to 'zen/shutdown.cpp')
-rwxr-xr-xzen/shutdown.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/zen/shutdown.cpp b/zen/shutdown.cpp
index 1794e4a8..a25e9c64 100755
--- a/zen/shutdown.cpp
+++ b/zen/shutdown.cpp
@@ -18,8 +18,7 @@ void zen::shutdownSystem() //throw FileError
//https://linux.die.net/man/2/reboot => needs admin rights!
//"systemctl" should work without admin rights:
- shellExecute("sleep 1; systemctl poweroff", ExecutionType::ASYNC); //throw FileError
- //sleep 1: give FFS some time to properly shut down!
+ shellExecute("systemctl poweroff", ExecutionType::SYNC); //throw FileError
}
@@ -27,10 +26,20 @@ void zen::shutdownSystem() //throw FileError
void zen::suspendSystem() //throw FileError
{
//"systemctl" should work without admin rights:
- shellExecute("systemctl suspend", ExecutionType::ASYNC); //throw FileError
+ shellExecute("systemctl suspend", ExecutionType::SYNC); //throw FileError
}
+
+void zen::terminateProcess(int exitCode)
+{
+ std::exit(exitCode); //[[noreturn]]; "Stack is not unwound: destructors of variables with automatic storage duration are not called." => perfect
+ //don't use std::abort() => crashes process with "EXC_CRASH (SIGABRT)" on macOS
+ for (;;) //why still here?? => crash deliberately!
+ *reinterpret_cast<volatile int*>(0) = 0; //crude but at least we'll get crash dumps if it happens
+}
+
+
/*
Command line alternatives:
bgstack15