delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/10/09/04:00:08

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Tue, 9 Oct 2007 09:59:34 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: file locking behaviour
Message-ID: <20071009075934.GD20400@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <21e1598b0710081432g3cedf377wbb69d023cf08bb22 AT mail DOT gmail DOT com> <21e1598b0710081437m3f43ae06k9b2f58ec41819be6 AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <21e1598b0710081437m3f43ae06k9b2f58ec41819be6@mail.gmail.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019