How do I find the file handles that my process has opened in Linux?

后端 未结 9 897
长发绾君心
长发绾君心 2021-02-04 12:16

When we perform a fork in Unix, open file handles are inherited, and if we don\'t need to use them we should close them. However, when we use libraries, file handles may be open

9条回答
  •  鱼传尺愫
    2021-02-04 12:38

    In Linux you can check /proc//fd directory - for every open fd there will be a file, named as handle. I'm almost sure this way is non-portable.

    Alternatively you can use lsof - available for Linux, AIX, FreeBSD and NetBSD, according to man lsof.

提交回复
热议问题