My code needs to go through files in a directory, picking only those, which are currently opened (for writing) by any other process on the system.
The ideal solution would apply for all Unixes, but I'll settle for a Linux-only.
The program is written in Python, but I can add a custom C-function, if I have to -- I just need to know, what API is available for this...
One suggestion I found was to go through all file-descriptors under Linux
/proc, resolving their links to see, if they point at the file of interest. But that seems rather heavy...
I know, for example, that opening a file increases its reference count -- filesystem will not deallocate blocks of an opened file even if it is deleted -- until it is closed -- the feature relied upon by
Perhaps, a user process can get access to these records in the kernel?