I want to get the pid of the thread created by pthread_create, so that I can know which thread is my working thread in the outputs of ps command.
- posted
15 years ago
I want to get the pid of the thread created by pthread_create, so that I can know which thread is my working thread in the outputs of ps command.
U are referring to kernel right?
It is in fs/proc/base.c: proc_task_read() function (which is called when u try to read the directory /proc/xxxx/task):
Following function is shown:
/* f_version caches the tgid value that the last readdir call couldn't * return. lseek aka telldir automagically resets f_version to
The above for-loop will print out all the thread ID of the particular process, eg:
ls /proc/3407/task/
3407 3413 3427 3435 3436 4303 4304 4798ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.