Use prctl on Linux to follow standard GNU/Linux functions
This commit is contained in:
parent
ff84a85f43
commit
49e5cbe5af
9
thpool.c
9
thpool.c
|
@ -8,9 +8,6 @@
|
|||
*
|
||||
********************************/
|
||||
|
||||
#if defined(__linux__)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
@ -18,6 +15,9 @@
|
|||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#if defined(__linux__)
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#include "thpool.h"
|
||||
|
||||
#ifdef THPOOL_DEBUG
|
||||
|
@ -306,7 +306,8 @@ static void* thread_do(struct thread* thread_p){
|
|||
sprintf(thread_name, "thread-pool-%d", thread_p->id);
|
||||
|
||||
#if defined(__linux__)
|
||||
pthread_setname_np(thread_p->pthread, thread_name);
|
||||
/* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */
|
||||
prctl(PR_SET_NAME, thread_name);
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
pthread_setname_np(thread_name);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue