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

不问归期 提交于 2019-12-11 20:42:39

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/26508413/linux-c-c-how-to-find-pid-from-a-threadid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!