Get list of open files (descriptors) in OS X

前端 未结 8 1280
难免孤独
难免孤独 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 01:56

    I had a hard time getting Activity Monitor to show open files for a process that was running as root (via sudo). The original question mentions lsof, and it does the trick exactly. If you know the process name or PID, it's super quick.

    Find processes by name:

    lsof -c processname
    

    Find processes by PID:

    lsof -p 123
    

    (Prefix with sudo as needed, such as if you are not the owner of the process.)

提交回复
热议问题