From d38e36b98f249ae1fd30fa9e7a454b784a9b014d Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 20 Oct 2014 21:50:49 +0200 Subject: osdep: shorten thread name on glibc only Instead of affecting every platform, do this for glibc only (where it's known to be a problem), and only if the right error is returned. --- osdep/threads.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osdep/threads.c b/osdep/threads.c index 2a5938cee5..7a6174eb79 100644 --- a/osdep/threads.c +++ b/osdep/threads.c @@ -15,6 +15,7 @@ * with mpv. If not, see . */ #include +#include #include "config.h" @@ -46,10 +47,13 @@ int mpthread_mutex_init_recursive(pthread_mutex_t *mutex) void mpthread_set_name(const char *name) { - char tname[16]; - snprintf(tname, sizeof(tname), "mpv %s", name); + char tname[80]; + snprintf(tname, sizeof(tname), "mpv/%s", name); #if HAVE_GLIBC_THREAD_NAME - pthread_setname_np(pthread_self(), tname); + if (pthread_setname_np(pthread_self(), tname) == ERANGE) { + tname[15] = '\0'; // glibc-checked kernel limit + pthread_setname_np(pthread_self(), tname); + } #elif HAVE_BSD_THREAD_NAME pthread_set_name_np(pthread_self(), tname); #elif HAVE_OSX_THREAD_NAME -- cgit v1.2.3