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: Problem getting flock with timeout to work


Corinna,

thanks for your feedback!

2009/3/12 Corinna Vinschen <corinna-cygwin@cygwin.com>:
> On Mar 12 17:44, Robert Klemme wrote:
>> The second flock does not start the command as I expect it to be.
>>
>> I am referring to the man page of flock which says this about option -w:
>>
>> Fail ?(with an exit code of 1) if the lock cannot be acquired within
>> seconds seconds. ?Decimal fractional values are allowed.
>>
>> So, since the second flock obviously cannot obtain the lock in time, I
>> would have expected it to fail and not execute the command given.
>> This is at least a documentation issue as flock's behavior and
>> documentation do not match IMHO.
>
> This scenario (your first testcase) works fine with Cygwin 1.7 with my
> fix from a couple of hours ago. ?I missed the fact that BSD flock lock
> semantic allows to set both lock types (LOCK_SH/LOCK_EX) regardless of
> the read/write mode in which the file has been opened, in contrast
> to POSIX lock semantic. ?That's fixed now and other than that glitch,
> it worked.

Hey, that's good news!

> However...

> Cygwin won't be able to support the scenario from your second testcase
> for the time being. ?The reason is that in this scenario
>
> ?(
> ? ?flock -s 200
> ? ?...
> ?) 200> lockfile
>
> the lock will end when the flock process exits. ?The lock can only
> persist as long as the process which created the lock, or any of the
> child applications which inherited the file descriptor, still runs. ?We
> can't maintain a global file descriptor table with lock information like
> the OS or what a master process could do if Cygwin would be designed so.

Thank you for the explanation!

> I know that's bad news, it certainly is for me since I thought I had
> implemented flock with full BSD semantics, but we just can't do that
> for now.

For me this is good enough - I find the variant "flock -c" better anyway. :-)

Thank you for looking into this!  Sorry for the intermediate confusion
about your "wrong" Linux.

Kind regards

robert

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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