How can I programmatically get the list of open file descriptors for a given PID on OS X?

前端 未结 1 1069
谎友^
谎友^ 2021-02-09 22:06

Everything I\'ve seen says to use lsof -p, but I\'m looking for something that doesn\'t require a fork/exec.

For example on Linux one can simply walk

相关标签:
1条回答
  • 2021-02-09 22:30

    You can use proc_pidinfo with the PROC_PIDLISTFDS option to enumerate the files used by a given process. You can then use proc_pidfdinfo on each file in turn with the PROC_PIDFDVNODEPATHINFO option to get its path.

    0 讨论(0)
提交回复
热议问题