mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 03:33:27 -03:00
Add Windows shutdown handler
This commit is contained in:
parent
9e9b48df72
commit
ddebde71ef
1 changed files with 11 additions and 0 deletions
11
src/init.cpp
11
src/init.cpp
|
@ -298,6 +298,7 @@ void Shutdown()
|
||||||
* The execution context the handler is invoked in is not guaranteed,
|
* The execution context the handler is invoked in is not guaranteed,
|
||||||
* so we restrict handler operations to just touching variables:
|
* so we restrict handler operations to just touching variables:
|
||||||
*/
|
*/
|
||||||
|
#ifndef WIN32
|
||||||
static void HandleSIGTERM(int)
|
static void HandleSIGTERM(int)
|
||||||
{
|
{
|
||||||
fRequestShutdown = true;
|
fRequestShutdown = true;
|
||||||
|
@ -307,6 +308,14 @@ static void HandleSIGHUP(int)
|
||||||
{
|
{
|
||||||
fReopenDebugLog = true;
|
fReopenDebugLog = true;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
|
||||||
|
{
|
||||||
|
fRequestShutdown = true;
|
||||||
|
Sleep(INFINITE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
static void registerSignalHandler(int signal, void(*handler)(int))
|
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
|
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
#else
|
||||||
|
SetConsoleCtrlHandler(consoleCtrlHandler, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::set_new_handler(new_handler_terminate);
|
std::set_new_handler(new_handler_terminate);
|
||||||
|
|
Loading…
Add table
Reference in a new issue