How to check if a file has been opened by another application in C++?

c++, file-io, linux, process

Solution

Not only the standard library does not have this funcionality, it's not even possible in general. You could (on linux) check `/proc/*/fd` — but it is possible that your program does not have permission to do it on processes from other users (this is the default in Ubuntu, for instance).

Problem

I know, that there's the `is_open()` function in C++, but I want one program to check if a file hasn't been opened by another application. Is there any way to do it using standard library? EDIT - Clarified in the answers that this is for a Linux application.

Original source