From cbd5f8dce45902deb0972fc6730fb6d3ca0f6bb1 Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 28 Oct 2026 10:26:20 -0500 Subject: [PATCH] init: do not rename the main thread in Shutdown() Shutdown() called RenameThread("hush-shutoff") on the main thread. On Linux that sets /proc//comm, i.e. the process name, so for the whole shutdown (wallet flush, chainstate flush, LevelDB closes) the node no longer matched 'pgrep -x dragonxd' / pidof while it still held the datadir and LevelDB locks. pgrep-based restart scripts took that as "exited" and relaunched it early; on regtest pgrep stopped matching about 1 s after 'stop' in 10/10 runs while the old process was alive. Keep the process name until exit. Worker threads keep their own names. Nothing depends on "hush-shutoff": no hit in src/, qa/, contrib/ or util/, and the ObsidianDragon GUI only works around the rename by also checking the exe link. Co-Authored-By: Claude Opus 5.5 --- src/init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 34403e3c1..776699fa9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -211,9 +211,9 @@ void Shutdown() /// for example if the data directory was found to be locked. /// Be sure that anything that writes files or flushes caches only does this if the respective /// module was initialized. - static char shutoffstr[128]; - sprintf(shutoffstr,"%s-shutoff","hush"); - RenameThread(shutoffstr); + // Do not RenameThread() here: Shutdown() runs on the main thread, whose name is the process name + // (/proc//comm). Renaming it made 'pgrep -x dragonxd' stop matching a node that was still + // shutting down and holding its locks, so pgrep-based restart scripts relaunched it too early. mempool.AddTransactionsUpdated(1); if(fDebug) {