![]() |
|
go ahead... be a heretic | |
PerlMonks |
File locking; downgrade an exclusive to a shared lockby The_Dj (Sexton) |
on Jul 12, 2013 at 02:25 UTC ( #1043858=perlquestion: print w/replies, xml ) | Need Help?? |
The_Dj has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Monks. I can't believe no-one has solved this so it must be that my google-fu has failed me. Simple lockfile for concurrency. This is on Windows 2003/ActivePerl 5.8, and the locking works. The problem is... Sometimes the process needs to be killed, and for that someone needs to read that file. Notepad works fine, but for some reason the people who do this try to open the file in vim (despite being windows people :-|) Vim honors the exclusive lock, and shows no content. Vim will read the file if it's only a shared lock. If I just flock (LF,LOCK_SH); the exclusive lock remains. But if I flock (LF,LOCK_UN); flock(LF,LOCK_SH); then I risk a race condition. A random stab at flock (LF,LOCK_UN|LOCK_SH) didn't work either. I can't install extra modules because reasons. Thanks for any help!
Back to
Seekers of Perl Wisdom
|
|