From af6ecbc69bd613649c8ac68b825cc39a50b1adc7 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Thu, 29 Dec 2022 04:03:53 -0500 Subject: [PATCH] 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 --- src/bees-trace.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/bees-trace.cc b/src/bees-trace.cc index 9e9c71f..d04d4c1 100644 --- a/src/bees-trace.cc +++ b/src/bees-trace.cc @@ -111,9 +111,7 @@ void BeesNote::set_name(const string &name) { tl_name = name; - catch_all([&]() { - DIE_IF_MINUS_ERRNO(pthread_setname_np(pthread_self(), name.c_str())); - }); + pthread_setname(name); } string @@ -134,19 +132,12 @@ BeesNote::get_name() } // 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 // ...by default? ...for the main thread? // ...except during exception handling? // ...randomly? - return buf; + return pthread_getname(); } BeesNote::ThreadStatusMap