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
