Get list of open files (descriptors) in OS X

前端 未结 8 1274
难免孤独
难免孤独 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:00

    The clean and simple approach to inspect the current process (i.e. the equivalent of /proc/self/fd on Linux) is to use ls /dev/fd/:

    e.g.

    $ touch "file"
    $ exec 3<>file
    
    $ ls /dev/fd/    
    
    0 1 2 3
    

提交回复
热议问题