Linux File Locking on Network Files
Posted on 2014-11-13
I am try to implement a file locking system within my application which is running in Linux.
I use flock to lock the file as shared (LOCK_SH) when reading and as exclusive (LOCK_EX) when writing. I'm also perform the lock as non-blocking (LOCK_NB).
I tested the file locking of a networked file by running 2 instances of my application on the same PC simultaneously, and I can see that one will wait to write while the other is in the process of writing.
When I run one instance on one PC and another instance on another PC, I am unable to see that the either PC recognizes the network file as locked.
What is the proper way to get networked PCs to recognize when a file is locked?
I am currently running Fedora 19 and my application is written in C.