eina - thread naming - when naming thread, cut off at 15 chars

automatically cut off at 15 chars (and add 0 byte) to ensure we get a
name, but just truncate it if it is too long.
This commit is contained in:
Carsten Haitzler 2015-09-10 15:15:01 +09:00
parent 5625aac4d4
commit 350698bada
1 changed files with 8 additions and 1 deletions

View File

@ -174,7 +174,14 @@ EAPI Eina_Bool
eina_thread_name_set(Eina_Thread t, const char *name)
{
#ifdef EINA_HAVE_PTHREAD_SETNAME
if (pthread_setname_np((pthread_t)t, name) == 0) return EINA_TRUE;
char buf[16];
if (name)
{
strncpy(buf, name, 15);
buf[15] = 0;
}
else buf[0] = 0;
if (pthread_setname_np((pthread_t)t, buf) == 0) return EINA_TRUE;
#endif
return EINA_FALSE;
}