mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
trace: use pthread_setname wrapper
libcrucible can deal with the Linux kernel and/or libc's thread name limitations. No need to duplicate that work in bees. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
563e584da4
commit
af6ecbc69b
@ -111,9 +111,7 @@ void
|
|||||||
BeesNote::set_name(const string &name)
|
BeesNote::set_name(const string &name)
|
||||||
{
|
{
|
||||||
tl_name = name;
|
tl_name = name;
|
||||||
catch_all([&]() {
|
pthread_setname(name);
|
||||||
DIE_IF_MINUS_ERRNO(pthread_setname_np(pthread_self(), name.c_str()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
@ -134,19 +132,12 @@ BeesNote::get_name()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OK try the pthread name next.
|
// OK try the pthread name next.
|
||||||
char buf[24];
|
|
||||||
memset(buf, '\0', sizeof(buf));
|
|
||||||
int err = pthread_getname_np(pthread_self(), buf, sizeof(buf));
|
|
||||||
if (err) {
|
|
||||||
return string("pthread_getname_np: ") + strerror(err);
|
|
||||||
}
|
|
||||||
buf[sizeof(buf) - 1] = '\0';
|
|
||||||
|
|
||||||
// thread_getname_np returns process name
|
// thread_getname_np returns process name
|
||||||
// ...by default? ...for the main thread?
|
// ...by default? ...for the main thread?
|
||||||
// ...except during exception handling?
|
// ...except during exception handling?
|
||||||
// ...randomly?
|
// ...randomly?
|
||||||
return buf;
|
return pthread_getname();
|
||||||
}
|
}
|
||||||
|
|
||||||
BeesNote::ThreadStatusMap
|
BeesNote::ThreadStatusMap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user