mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibThreading: Set system threads' names based on Thread::thread_name()
This commit is contained in:
committed by
Gregory Bertilson
parent
c4e95079e1
commit
3cb39baa44
Notes:
github-actions[bot]
2026-02-06 11:03:34 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/3cb39baa44f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7601 Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/cqundefine
@@ -77,6 +77,20 @@ void Thread::start()
|
||||
[](void* arg) -> void* {
|
||||
auto self = adopt_ref(*static_cast<Thread*>(arg));
|
||||
|
||||
{
|
||||
// pthread_setname_np expects a 16-byte or shorter null-terminated C string.
|
||||
auto thread_name = self->thread_name().substring(0, min(self->thread_name().length(), 15));
|
||||
#if defined(AK_OS_MACOS)
|
||||
pthread_setname_np(thread_name.characters());
|
||||
#elif defined(AK_OS_OPENBSD)
|
||||
pthread_set_name_np(pthread_self(), thread_name.characters());
|
||||
#elif defined(AK_OS_NETBSD)
|
||||
pthread_setname_np(pthread_self(), "%s", const_cast<char*>(thread_name.characters()));
|
||||
#else
|
||||
pthread_setname_np(pthread_self(), thread_name.characters());
|
||||
#endif
|
||||
}
|
||||
|
||||
auto exit_code = self->m_action();
|
||||
|
||||
auto expected = Threading::ThreadState::Running;
|
||||
|
||||
Reference in New Issue
Block a user