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:
furszy
2023-05-20 10:51:17 -03:00
parent 3c06926cf2
commit 3b2c61e819
9 changed files with 32 additions and 14 deletions

View File

@@ -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;
}