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

后端 未结 9 905
长发绾君心
长发绾君心 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条回答
  •  -上瘾入骨i
    2021-02-04 12:29

    If the libraries are opening files you don't know about, how do you know they don't need them after a fork? Unexported handles are an internal library detail, if the library wants them closed it will register an atfork() handler to close them. Walking around behind some piece of code closing its file handles behind its back will lead to subtle hard to debug problems since the library will error unexpectedly when it attempts to work with a handle it knows it opened correctly, but did not close.

提交回复
热议问题