Skip to content

Commit 4715037

Browse files
committed
Merge #17038: Don't rename main thread at process level
07e4bdb Don't rename main thread at process level (Wladimir J. van der Laan) Pull request description: Set only the internal name for the main threads. Fixes #17036 for both `bitcoind` and `bitcoin-qt`. After this, e.g. `killall` works again for either. ACKs for top commit: promag: Tested ACK 07e4bdb, `killall bitcoind` and `killall bitcoin-qt` now just works! jonatack: ACK 07e4bdb `killall bitcoind` shuts down bitcoind mainnet/testnet/regtest, `killall bitcoin-qt` shuts down `./src/qt/bitcoin-qt`, tests pass, very light code review. Good idea to add the `@note` warning. Thanks! Tree-SHA512: 8f310ae646c83a02de7cc6869aa9aca1d53613d8fb762d05e3dfa52e17ca82abeb99044564cf7ba45b3c4b320e65bf8315d0e8834a9e696f097be5af638c6fd9
2 parents 284cd31 + 07e4bdb commit 4715037

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)