MWeiss
MWeiss

Reputation: 13

Linux c/c++ How to find PID from a ThreadID

I'm currently writing a FUSE application that should implement process based access rights. I now stumble about the fact, that FUSE only provides the ThreadID, not the ProcessID. Now I need to find the PID (or Thread Group ID) for the given Thread ID of a different process.

I noticed that the proc fs provides Thread based information (even a ls /proc does not show none PID TID's they can still be accessed through /proc/<TID>/) in this way I can ask /proc/<TID>/status about the Tgid, but as my FUSE app will serve hundreds of requests per second, I feel this might not be the best way here.

Does anyone know a syscall or function of the form gettgid(tid) to be used here?

Upvotes: 1

Views: 1616

Answers (1)

ChrisWard1000
ChrisWard1000

Reputation: 536

I think you need to use /proc/ to get this info yourself. I can't find any syscall or posix functions that do what you need. /proc/ should be fast as it isn't a real fs on disk and I think it's the only choice.

Upvotes: 1

Related Questions