Skip to content

Commit 07e4bdb

Browse files
committed
Don't rename main thread at process level
Set only the internal name. Fixes #17036 for both `bitcoind` and `bitcoin-qt`.
1 parent f4a0d27 commit 07e4bdb

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/bitcoind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static bool AppInit(int argc, char* argv[])
4545

4646
bool fRet = false;
4747

48-
util::ThreadRename("init");
48+
util::ThreadSetInternalName("init");
4949

5050
//
5151
// Parameters

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ int GuiMain(int argc, char* argv[])
416416
std::tie(argc, argv) = winArgs.get();
417417
#endif
418418
SetupEnvironment();
419-
util::ThreadRename("main");
419+
util::ThreadSetInternalName("main");
420420

421421
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode();
422422

src/util/threadnames.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@ void util::ThreadRename(std::string&& name)
6060
SetThreadName(("b-" + name).c_str());
6161
SetInternalName(std::move(name));
6262
}
63+
64+
void util::ThreadSetInternalName(std::string&& name)
65+
{
66+
SetInternalName(std::move(name));
67+
}

src/util/threadnames.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
namespace util {
1111
//! Rename a thread both in terms of an internal (in-memory) name as well
1212
//! as its system thread name.
13+
//! @note Do not call this for the main thread, as this will interfere with
14+
//! UNIX utilities such as top and killall. Use ThreadSetInternalName instead.
1315
void ThreadRename(std::string&&);
1416

17+
//! Set the internal (in-memory) name of the current thread only.
18+
void ThreadSetInternalName(std::string&&);
19+
1520
//! Get the thread's internal (in-memory) name; used e.g. for identification in
1621
//! logging.
1722
const std::string& ThreadGetInternalName();

0 commit comments

Comments
 (0)