[fpc-devel] need to call FpFlock to unlock file in FileClose?

Michael Van Canneyt michael at freepascal.org
Sat Oct 30 11:05:05 CEST 2010



On Sat, 30 Oct 2010, Vinzent Höfler wrote:

> On Sat, 30 Oct 2010 00:18:15 +0200, Seth Grover <sethdgrover at gmail.com> 
> wrote:
>
>> My question is this: if FileOpen automagically handles the file
>> locking through a call to DoFileLocking, wouldn't it be more correct
>> for FileClose handle unlocking as well?
>
> It should, if it's necessary.
>
> Interestingly
>
> "man 2 flock" says:
>
> |Furthermore, the lock is released either by an explicit LOCK_UN operation on
> |any of these duplicate descriptors, or when all such descriptors have been
> |closed.
>
> So I would expect the lock to disappear when the file is closed. Nitpicking
> people might say, this only applies to duplicated descriptors, but then
> what's the point?
>
> So, actually I'm inclined to consider that a bug in the underlying OS.

I tend to agree with this. The reason the explicit unlock is not done is that 
the close should do it implicitly (as per the man page).

But are you sure the first close() operation actually succeeded ?

Michael.


More information about the fpc-devel mailing list