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: Bruno Haible
Subject: Re: Preliminary patch for flock (just for discussion)
Date: Fri, 3 Oct 2008 14:19:05 +0200
User-agent: KMail/1.5.4

Paolo Bonzini wrote:
> > * 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.

Very good point. You can write flock() in terms of fcntl()? Also, in glibc
we have code for lockf() in terms of fcntl.

The native OS support of these three APIs is that
  - fcntl with F_SETLK is supported on all Unix platforms.
  - lockf is supported on all Unix platforms except Cygwin, BeOS.
  - flock is supported on all Unix platforms except AIX, HP-UX, Solaris, BeOS.

So with the two replacements for flock() and lockf() in place, and with
an implementation of fcntl F_SETLK for mingw, we will get all three APIs
supported in gnulib across all platforms!

> I don't think having an fcntl wrapper in gnulib makes any sense).

Why not? It does not need to support all possible control commands, only those
that we chose to provide.

Bruno





reply via email to

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