diff options
author | Chun Kuan Lee <ken2812221@gmail.com> | 2018-04-30 23:31:11 +0800 |
---|---|---|
committer | Chun Kuan Lee <ken2812221@gmail.com> | 2018-05-01 19:39:00 +0800 |
commit | ddebde71efe17eb3b1367948e9b728f6a86696ab (patch) | |
tree | 045a78199721a4b771b8fd46b37d3f2687a2aff4 /src | |
parent | 9e9b48df72dbd68a827f984861779e1c6bd842a4 (diff) | |
download | bitcoin-ddebde71efe17eb3b1367948e9b728f6a86696ab.tar.xz |
Add Windows shutdown handler
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp index 99dab605ac..f27f148126 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) { fReopenDebugLog = 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)) @@ -909,6 +918,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); |