Forum > Operating Systems

Ubuntu: How to get pthread_t from tid [was: AV when using pthread_getname_np()]

<< < (4/5) > >>

sstvmaster:

--- Quote from: Pascal on June 27, 2022, 02:16:40 pm ---Well, is there really no way to get pthread_t from tid?

--- End quote ---

And what about pthread_self: https://www.delftstack.com/howto/c/pthread-get-thread-id-in-c/

Pascal:
Uff, this makes no sense as i have to query the ThreadManager of the third party app.

Pascal:

--- Quote from: sstvmaster on June 27, 2022, 02:32:24 pm ---
--- Quote from: Pascal on June 27, 2022, 02:16:40 pm ---Well, is there really no way to get pthread_t from tid?

--- End quote ---

And what about pthread_self: https://www.delftstack.com/howto/c/pthread-get-thread-id-in-c/

--- End quote ---
This works inside the thread. But as i am debugging another process i need a function which converts the tid to a pthread_t to make a call to pthread_getname_np().

Zvoni:

--- Quote from: Pascal on June 27, 2022, 03:20:53 pm ---
--- Quote from: sstvmaster on June 27, 2022, 02:32:24 pm ---
--- Quote from: Pascal on June 27, 2022, 02:16:40 pm ---Well, is there really no way to get pthread_t from tid?

--- End quote ---

And what about pthread_self: https://www.delftstack.com/howto/c/pthread-get-thread-id-in-c/

--- End quote ---
This works inside the thread. But as i am debugging another process i need a function which converts the tid to a pthread_t to make a call to pthread_getname_np().

--- End quote ---

And you didn't read my answer:

--- Quote ---
--- Quote from: Pascal on June 27, 2022, 11:42:38 am ---Or should i use reading "/proc/[pid]/task/[tid]/comm"?

--- End quote ---
From the same link: https://linux.die.net/man/3/pthread_getname_np

--- Quote ---Notes

pthread_setname_np() internally writes to the thread specific comm file under /proc filesystem: /proc/self/task/[tid]/comm.
pthread_getname_np() retrieves it from the same location.
--- End quote ---

--- End quote ---

Pascal:

--- Quote from: Zvoni on June 27, 2022, 03:29:35 pm ---And you didn't read my answer:

--- Quote ---
--- Quote from: Pascal on June 27, 2022, 11:42:38 am ---Or should i use reading "/proc/[pid]/task/[tid]/comm"?

--- End quote ---
From the same link: https://linux.die.net/man/3/pthread_getname_np

--- Quote ---Notes

pthread_setname_np() internally writes to the thread specific comm file under /proc filesystem: /proc/self/task/[tid]/comm.
pthread_getname_np() retrieves it from the same location.
--- End quote ---

--- End quote ---

--- End quote ---
I've read and understood it. But my original goal was to use pthread_getname_np instead of /proc/[tid]/comm.
It's implemented that way in trunk now as i wasn't able to find a solution to get a pthread_id from an tid.

Thanks for your efforts to help.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version