in reply to correct usage of flock?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: correct usage of flock?
by cLive ;-) (Prior) on Jun 06, 2001 at 06:53 UTC | |
by bluto (Curate) on Jun 06, 2001 at 18:42 UTC | |
by sierrathedog04 (Hermit) on Jun 06, 2001 at 19:31 UTC | |
by cLive ;-) (Prior) on Jun 06, 2001 at 20:15 UTC | |
by sierrathedog04 (Hermit) on Jun 06, 2001 at 23:29 UTC | |
by bluto (Curate) on Jun 08, 2001 at 18:56 UTC |