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: file locking behaviour


On Oct  8 23:37, Damjan Lango wrote:
> Hello!
> 
> I have a program that uses:
> 
> lock.l_type = F_WRLCK;
> fcntl(log->handle, F_SETLK, &lock)
> 
> the file is then locked also for reads, is that correct behaviour?
> I thought that only writing would be locked.
> on unix the file stays readable even if using the above code.

The behaviour is correct as far as mandatory locking is concerned.
Under POSIX file locking is supposed to be advisory locking which
doesn't actually enforce the lock.  The problem for us is the fact
that Windows does only implement mandatory locking and that's what
is used in Cygwin for now.  Implementing advisory file locking is
on my ToDo list for quite some time now but..., well...
http://cygwin.com/contrib.html


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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]