aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 3239252778..7d8f462ef1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -298,6 +298,7 @@ void Shutdown()
* The execution context the handler is invoked in is not guaranteed,
* so we restrict handler operations to just touching variables:
*/
+#ifndef WIN32
static void HandleSIGTERM(int)
{
fRequestShutdown = true;
@@ -307,6 +308,14 @@ static void HandleSIGHUP(int)
{
g_logger->m_reopen_file = true;
}
+#else
+static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
+{
+ fRequestShutdown = true;
+ Sleep(INFINITE);
+ return true;
+}
+#endif
#ifndef WIN32
static void registerSignalHandler(int signal, void(*handler)(int))
@@ -912,6 +921,8 @@ bool AppInitBasicSetup()
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly
signal(SIGPIPE, SIG_IGN);
+#else
+ SetConsoleCtrlHandler(consoleCtrlHandler, true);
#endif
std::set_new_handler(new_handler_terminate);