diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -306,15 +306,6 @@ } #endif - try { - if (!fs::remove(GetPidFile(*node.args))) { - LogPrintf("%s: Unable to remove PID file: File does not exist\n", - __func__); - } - } catch (const fs::filesystem_error &e) { - LogPrintf("%s: Unable to remove PID file: %s\n", __func__, - fsbridge::get_filesystem_error_message(e)); - } node.chain_clients.clear(); UnregisterAllValidationInterfaces(); GetMainSignals().UnregisterBackgroundSignalScheduler(); @@ -324,6 +315,17 @@ node.mempool = nullptr; node.chainman = nullptr; node.scheduler.reset(); + + try { + if (!fs::remove(GetPidFile(*node.args))) { + LogPrintf("%s: Unable to remove PID file: File does not exist\n", + __func__); + } + } catch (const fs::filesystem_error &e) { + LogPrintf("%s: Unable to remove PID file: %s\n", __func__, + fsbridge::get_filesystem_error_message(e)); + } + LogPrintf("%s: done\n", __func__); }