1
0
Fork 0

Feature: Support pthread_setname_np()

This commit is contained in:
Philipp Schafft 2022-03-20 16:12:21 +00:00
parent 04e4f7eb60
commit 85d54c53de
1 changed files with 8 additions and 0 deletions

View File

@ -314,6 +314,14 @@ thread_type *thread_create_c(const char *name, void *(*start_routine)(void *),
if (pthread_create (&thread->sys_thread, &attr, _start_routine, start) == 0)
{
pthread_attr_destroy (&attr);
#ifdef HAVE_PTHREAD_SETNAME_NP
if (pthread_setname_np(thread->sys_thread, name) != 0) {
/* If the call above did not work it was likely due to name limit restrictions.
* In that case we retry with a fixed name so we do not inherit our parent's name.
*/
pthread_setname_np(thread->sys_thread, "Worker");
}
#endif
return thread;
}
else