Get list of open files (descriptors) in OS X

前端 未结 8 1272
难免孤独
难免孤独 2020-12-05 01:28

I would like to get a list of open files in a process on os x (10.9.1). In Linux I was able to get this from /proc/PID/fd. However I\'m not sure how to get the

8条回答
  •  北海茫月
    2020-12-05 02:04

    Since you asked "Is there any other support [than lsof] available?", try this:

    Create a command line tool using the "proc_pidinfo" C API referenced in the selected answer to this question: How can I programmatically get the list of open file descriptors for a given PID on OS X?

    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.

提交回复
热议问题