Set public thread name

This allows to identify Ardour thread using standard unix
tools (ps, htop) and inspect priorities, CPU load etc.
This commit is contained in:
Robin Gareus 2020-03-29 13:55:20 +02:00
parent f81442c3bf
commit d6a38d5450
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -153,6 +153,14 @@ pthread_set_name (const char *str)
/* copy string and delete it when exiting */ /* copy string and delete it when exiting */
thread_name.set (strdup (str)); // leaks thread_name.set (strdup (str)); // leaks
#if !defined PLATFORM_WINDOWS && defined _GNU_SOURCE
/* set public thread name, up to 16 chars */
char ptn[16];
memset (ptn, 0, 16);
strncpy (ptn, str, 15);
pthread_setname_np (pthread_self(), ptn);
#endif
} }
const char * const char *