Wednesday 21 December 2016

linux - pthread_setname_np failed, errno is 2



I want to set my thread name, and I check my linux glibc verison is 2.12, include the pthread_setname_np API, but i got errno 2 when execute pthread_setname_np, I found 2 is ENOENT,meant to "No such file or directory". I don't understand. but I found in my same code, pthread_setname_np return success in another linux system.
the version info of return success:

root@Gzpeak:/home/wzx/thread# uname -a
Linux Gzpeak 3.13.0-86-generic #130-Ubuntu SMP Mon Apr 18 18:27:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root@Gzpeak:/home/wzx/thread# cat /proc/version
Linux version 3.13.0-86-generic (buildd@lgw01-19) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #130-Ubuntu SMP Mon Apr 18 18:27:15 UTC 2016
root@Gzpeak:/home/wzx/thread# getconf GNU_LIBC_VERSION
glibc 2.19

the version info of return error:
[root@localhost wzx]#uname -a
Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost wzx]# cat /proc/version
Linux version 2.6.32-279.el6.x86_64 (mockbuild@x86-008.build.bos.redhat.com) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Wed Jun 13 18:24:36 EDT 2012
[root@localhost wzx]# getconf GNU_LIBC_VERSION
glibc 2.12

please someone tell me, tank you for any advice.


Answer



I found the answer in proc5 page, the "/proc/[pid]/task/[tid]/comm" file exists only since linux 2.6.33. the second linux version is 2.6.32, so pthread_setname_np return error although glibc is v2.12. BTW, @galka thank you for your advice, give me a way to find the answer.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...