Adds thread names on OS X

This commit is contained in:
Simone Mainardi 2018-04-13 18:35:09 +02:00
parent 820f1e9668
commit 078a0df62d
3 changed files with 17 additions and 0 deletions

View file

@ -26,6 +26,14 @@
/* **************************************************** */
static void* doRun(void* ptr) {
#ifdef __APPLE__
// Mac OS X: must be set from within the thread (can't specify thread ID)
char buf[MAX_PATH];
snprintf(buf, sizeof(buf), "ThreadPool worker");
if(pthread_setname_np(buf))
ntop->getTrace()->traceEvent(TRACE_WARNING, "Unable to set pthread name %s", buf);
#endif
((ThreadPool*)ptr)->run();
return(NULL);
}