This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreliable flock

On Apr  4 19:51, Andrey Repin wrote:
> If you mean the part about
> > BSD file locks created via flock are only propagated to the direct parent
> > process, not to grand parents or sibling processes. The locks are only valid
> > in the creating process, its parent process, and subsequently started child
> > processes sharing the same file descriptor.
> then that's a showstopper. In short, it makes the function literally useless.
> I can work around it in a given script, but... *sad panda*

The problem with BSD locks is that the way they are implemented requires
a common shared datastructure in all child processes of a common
ancestor process which opened the file.  This isn't available in Cygwin.
Implementing this is tricky and potentially costly so I only got around
to implement this for the direct ancestor process.  I'm open to
suggestions or even patches to make this work in full.  Have a look into
Cygwin's to see how locks are implemented.  Feel free to discuss
implementation details on the cygwin-developers ML.

Note that the same restrictions don't apply to POSIX locks since they
are working quite differently.

> Why they aren't real locks? What's use for "advisory locks"? "I think I may
> have a use for this file, but you are free to delete it, if you wish" ?

Unix systems usually implement file locking advisory, not mandatory.
Windows only implements mandatory locks which are incompatible in
behaviour with POSIX as well as BSD locks.  I guess you read that
there's a way to use Windows mandatory locks, too.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]