[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Preliminary patch for flock (just for discussion)
From: |
Bruno Haible |
Subject: |
Re: Preliminary patch for flock (just for discussion) |
Date: |
Fri, 3 Oct 2008 02:25:42 +0200 |
User-agent: |
KMail/1.5.4 |
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.
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.
Therefore, why not forget about flock() and implement lockf() instead?
* About the platforms.
Before doing a mingw port, IMO it is reasonable to cover the Unix platforms,
i.e. provide the support for Solaris, AIX, HP-UX in the flock() case or
for Cygwin in the lockf() case.
* About the code.
You don't need to test whether the platform is VER_PLATFORM_WIN32_NT or
not. Windows 95/98/ME is not a porting target any more. In fact, the
doc on msdn.microsoft.com does not mention any more which function were
supported on Windows 95/98/ME and which were not.
Bruno
[1] http://www.opengroup.org/susv3/functions/lockf.html
[2] http://www.opengroup.org/susv3/functions/fcntl.html
[3] http://linux.die.net/man/2/flock
[4] http://www.manpagez.com/man/2/flock/