mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Return EXIT_FAILURE on post-init fatal errors
It seems odd to return `EXIT_SUCCESS` when the node aborted execution due a fatal internal error or any post-init problem that triggers an unrequested shutdown. e.g. blocks or coins db I/O errors, disconnect block failure, failure during thread import (external blocks loading process error), among others. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -169,7 +169,7 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
|
||||
// Set this early so that parameter interactions go to console
|
||||
InitLogging(args);
|
||||
InitParameterInteraction(args);
|
||||
if (!AppInitBasicSetup(args)) {
|
||||
if (!AppInitBasicSetup(args, node.exit_status)) {
|
||||
// InitError will have been called with detailed error, which ends up on console
|
||||
return false;
|
||||
}
|
||||
@@ -238,6 +238,8 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
|
||||
SetSyscallSandboxPolicy(SyscallSandboxPolicy::SHUTOFF);
|
||||
if (fRet) {
|
||||
WaitForShutdown();
|
||||
} else {
|
||||
node.exit_status = EXIT_FAILURE;
|
||||
}
|
||||
Interrupt(node);
|
||||
Shutdown(node);
|
||||
@@ -264,5 +266,5 @@ MAIN_FUNCTION
|
||||
// Connect bitcoind signal handlers
|
||||
noui_connect();
|
||||
|
||||
return (AppInit(node, argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
return AppInit(node, argc, argv) ? node.exit_status.load() : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user