Amit Redij wrote:
I have process A & process B, writing &
reading a plain text data file
respectively. I can implement exclusive lock using fcntl() so that when A is
in the process of writing the file, B should not read at that instance.
However, I noticed that even if process A has got an exclusive lock on the
file, I can open the file manually (say vi) and modify the file.
fcntl gives you _discretionary_ locking. Both process A and
process B need to cooperate on the use of locks. So, if you're
able to open (and write, though you haven't menioned this) the
file, it's probably because vi isn't checking for the lock.
See also flock (which has different semantics than fcntl) and
search for unix/linux file locking mechanisms on google.
-Manish
--
"The statements and opinions expressed here are my own and do
not necessarily represent those of Oracle Corporation."