List all currently open file handles?
Question: > **Possible Duplicate:**  
>  [check what files are open in
> Python](http://stackoverflow.com/questions/2023608/check-what-files-are-
> open-in-python)

Hello,

Is it possible to obtain a list of all currently open file handles, I presume
that they are stored somewhere in the environment.

I am interested in theis function as I would like to safely handle any files
that are open when a fatal error is raised, i.e. close file handles and
replace potentially corrupted files with the original files.

I have the handling working but without knowing what file handles are open, I
am unable to implement this idea.

As an aside, when a file handle is initialised, can this be inherited by
another imported method?

Thank you


Answer: lsof, /proc/pid/fd/

