bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preliminary patch for flock (just for discussion)


From: Paolo Bonzini
Subject: Re: Preliminary patch for flock (just for discussion)
Date: Fri, 03 Oct 2008 08:33:24 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Bruno Haible wrote:
> Hi,
> 
> Richard W.M. Jones wrote:
>> here is a preliminary patch for flock support for Windows.
> 
> Three comments.
> 
> * About the function. Why flock() and not lockf()?
>   There are three APIs for locking:
>     - lockf in POSIX [1],
>     - fcntl in POSIX [2],
>     - flock in BSD and glibc [3][4].
> 
>   According to the gnulib doc (doc/posix-functions/lockf.texi,
>   doc/glibc-functions/flock.texi) lockf is supported on a wider range of
>   platforms than flock.

But lockf unlike flock does not support shared locks, which are very
useful.  I can take care of implementing it in terms of fcntl when
Richard's patch goes in.

>   Also, the man pages say that the relation between the POSIX locks and
>   flock are unspecified. Which means, flock can easily fail to detect that
>   a file is already locked in the POSIX sense.

If fcntl locks does not have this problem, we can implement flock in
terms of fcntl on all platforms that have fcntl locks.  So flock would
just provide a simpler interface (I don't think having an fcntl wrapper
in gnulib makes any sense).

Paolo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]