is an exclusive lock. That means that you can write or delete the file but others who use flock cannot. Therefore the correct approach is to makeflock(FILE,2);
the last line of your program. Then you are protected from race conditions.flock(FILE,8)
I tried it out on my Linux box, and it works great. You can unlink a file while you have an exclusive lock on it, and indeed that is the best way to prevent anyone from writing to it before you are finished deleting it.
In reply to Re: correct usage of flock?
by sierrathedog04
in thread correct usage of flock?
by cLive ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |