diff options
| author | Wladimir J. van der Laan <[email protected]> | 2018-05-07 14:31:08 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2018-05-07 14:33:03 +0200 |
| commit | 57aae632e28833c1ee33462858d79ed3de201a3c (patch) | |
| tree | 61f44d48debb0c7e6fc5d6175bbb9c79f2454d6f /src/init.cpp | |
| parent | Merge #13149: Handle unsuccessful fseek(...):s (diff) | |
| parent | Add Windows shutdown handler (diff) | |
| download | discoin-57aae632e28833c1ee33462858d79ed3de201a3c.tar.xz discoin-57aae632e28833c1ee33462858d79ed3de201a3c.zip | |
Merge #13131: Add Windows shutdown handler
ddebde7 Add Windows shutdown handler (Chun Kuan Lee)
Pull request description:
Exit properly when clicked the red X of Windows Console
Tree-SHA512: f030edd08868390662b42abfa1dc6bd702166c6c19f5b1f8e7482e202451e79fb6f37ea672c26c2eb0d32c367bfca86160fbee624696c53828f280b7070be6a0
Diffstat (limited to 'src/init.cpp')
| -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 323925277..7d8f462ef 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); |