fix(linux/freebsd): truncate thread names to 15 characters (#5527)

This commit is contained in:
Conn O'Griofa authored and GitHub committed 2026-08-19 23:31:03 -04:00
1 parent 6ad5f9735d
commit 9e1f089e1f
4 files changed
+10 -7

No files matched your search

+1 -1
View File
@@ -949,7 +949,7 @@ namespace platf {
*
* @param name Human-readable name to assign.
*/
void set_thread_name(const std::string &name);
void set_thread_name(std::string_view name);
void enable_mouse_keys();
+4 -2
View File
@@ -521,8 +521,10 @@ namespace platf {
}
}
void set_thread_name(const std::string &name) {
pthread_setname_np(pthread_self(), name.c_str());
void set_thread_name(std::string_view name) {
// Truncate name to fit in Linux/FreeBSD kernel's 16 byte limit
std::string tr_name {name.substr(0, 15)};
pthread_setname_np(pthread_self(), tr_name.c_str());
}
/**
+3 -2
View File
@@ -252,8 +252,9 @@ namespace platf {
pthread_set_qos_class_self_np(mac_priority, 0);
}
void set_thread_name(const std::string &name) {
pthread_setname_np(name.c_str());
void set_thread_name(std::string_view name) {
std::string thread_name {name};
pthread_setname_np(thread_name.c_str());
}
void enable_mouse_keys() {
+2 -2
View File
@@ -1130,8 +1130,8 @@ namespace platf {
}
}
void set_thread_name(const std::string &name) {
std::wstring wname = utf_utils::from_utf8(name);
void set_thread_name(std::string_view name) {
std::wstring wname = utf_utils::from_utf8(std::string {name});
HRESULT hr = SetThreadDescription(GetCurrentThread(), wname.c_str());
if (FAILED(hr)) {
BOOST_LOG(error) << "SetThreadDescription failed: " << hr;