After a research I made, I'm still not sure if there are APIs that allows you to open file exclusively, meaning, any other process would not be able to right to the file.
Please can someone give me a good reference/guide/note/manual that covers this topic?
Thanks a lot!
Edit: Advisory Locking is good enough.
To prevent file reading from multiple processess, all of them must implement the same locking mechanism.
One way would be using
flockmechanism, which is not available everywhere. Fromflock(2)manpage:Another way would be using a lockfile -- file alongside the original one indicating the lock is active. C11 specifies a modifier
xto mode infopen, which ensures that the file is always created and not opened if it already exists: