When using setuid/setgid, main thread don't have access to
/proc/self/task/[tid]/comm, which is owned by newly created
thread (root).
To fix this, pthread_setname_np() was moved to newly created
thread, and now it changes name for itself.
Signed-off-by: Igor Podoski <igor.podoski@ts.fujitsu.com>
pid(0),
ioprio_class(-1),
ioprio_priority(-1),
- cpuid(-1)
+ cpuid(-1),
+ thread_name(NULL)
{
}
}
if (pid && cpuid >= 0)
_set_affinity(cpuid);
+
+ pthread_setname_np(pthread_self(), thread_name);
return entry();
}
void Thread::create(const char *name, size_t stacksize)
{
+ assert(strlen(name) < 16);
+ thread_name = name;
+
int ret = try_create(stacksize);
if (ret != 0) {
char buf[256];
"failed with error %d", ret);
dout_emergency(buf);
assert(ret == 0);
- } else if (thread_id > 0) {
- assert(strlen(name) < 16);
- pthread_setname_np(thread_id, name);
}
}
pid_t pid;
int ioprio_class, ioprio_priority;
int cpuid;
+ const char *thread_name;
void *entry_wrapper();