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]

Re: 1.3.3 - fcntl locking + rename bug


Hey, Luke

You can't do that on windows :) It doesn't allow
to remove a file while you hold an open handle
to it.

Btw look at this sample of using MoveFile API, which
is used to implement the rename call:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/filesio_9bhh.asp

Hope this helps.

Luke Bakken wrote:
> 
> Hi all,
> 
> I've been fighting LPRng for about a month now trying to get it working on
> cygwin, and have finally succeeded. Hooray!
> 
> However, I think I have discovered a bug in the following situation, which
> occurs frequently in LPRng:
> 
> Open a status file (named lpq in LPRng's case) for WR, and get a lock on
> it with fcntl (call it lockfd).
> 
> Create a tempfile (tempfd), stuff it with info, and close tempfd.
> 
> Rename tempfile to status file - this causes error "Permission Denied".
> 
> Close lockfd.
> 
> To get LPRng to work sucessfully, I had to move the "close lockfd"
> *before* attempting to rename the tempfile.  I have written a small test
> program (composed mainly of code straight from LPRng) to verify the above
> behavior (locktest.c) and it does reproduce the problem as it occurs in
> LPRng on cygwin.  The test program (as well as LPRng) both work fine on my
> OpenBSD machine.
> 
> Attached is the output of cygcheck -s -v -r as well as the test program.
> 
> Thanks!  If people are interested in LPRng for Cygwin, please let me know
> - I'm now going to get the setuid stuff working.
> 
> Luke Bakken

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