This is the mail archive of the cygwin@cygwin.com 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: fcntl() bug? if called second times!


Hello,

Cygwin doesn't support advisory file locking. It implements file locking 
via the Win32 api LockFile*. Find out more here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/lockfile.asp

And more specifically this part:
[...]
Locking a portion of a file for shared access denies all processes write 
access to the specified region of the file, including the process that 
first locks the region. All processes can read the locked region.
[...]

In fact I think the Win32 error code returned in this case is 
ERROR_LOCK_VIOLATION and Cygwin translates it to EACCESS.

Some time before I started porting sendmail to Cygwin and met this 
problem. I decided to try to implement something like advisory file 
locking for Cygwin back then but lack of time prevented me from doing so 
:(

On Mon, 13 Jan 2003, Heiko Elger wrote:

> Hello,
> 
> I try to comiple an run the distcc package - but I get errors while running.
> I figured out, tha the problems are the fcntl() calls - perhaps
> ther is a bug in cygwin?
> The following code runs differently in cygwin and linux.
> If I want ro lock the whole file twice, but still the same process, I will
> get an "permission denied" error on cygwin.
> The same code works on linux!
> 
> ===> Cygwin console
>     heiko@HEIKO ~/src/fslock
>     $ ./fslocktest
>     Lock 1
>     Lock 2
>     lock failed: fslocktest.txt: Permission denied
> 
> ===> linux console
>     heiko@linux:~/src/fslock> ./fslocktest
>     Lock 1
>     Lock 2



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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]