Unreliable flock
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Apr 4 19:06:00 GMT 2016
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 flock.cc 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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160404/8fb64118/attachment.sig>
More information about the Cygwin
mailing list