[core] Trim thread name on Linux to 16 bytes

That is a hard limit, if you set a string bigger than that, it
doesn't get set.
This commit is contained in:
Thiago Marcos P. Santos
2016-07-14 19:57:02 +03:00
parent 4a1a7937ae
commit 4d9e824639

View File

@@ -26,7 +26,11 @@ void setCurrentThreadName(const std::string& name) {
pthread_setname_np(name.c_str());
#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 12)
pthread_setname_np(pthread_self(), name.c_str());
if (name.size() > 15) { // Linux hard limit (see manpages).
pthread_setname_np(pthread_self(), name.substr(0, 15).c_str());
} else {
pthread_setname_np(pthread_self(), name.c_str());
}
#endif
#endif
(void)name;