Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Fri, 9 Apr 2004 12:47:40 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Tom Rodman cc: cygwin AT cygwin DOT com Subject: Re: observation on cygwin file locking, just an FYI In-Reply-To: <200404091607.i39G7BaM019427@tigris.pounder.sol.net> Message-ID: References: <200404091607 DOT i39G7BaM019427 AT tigris DOT pounder DOT sol DOT net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.39 On Fri, 9 Apr 2004, Tom Rodman wrote: > Assume you have two hosts w/cygwin installed: one that sees script > foobar as a local file and one that is running this same foobar but > through a network drive. > > Based on tests, if bash is running the script "foobar", w/foobar > on a remote drive; then while foobar is > running on this remote box, assume you are now at the host > that has foobar on a local drive: > > o you may *rename* the script to say "foobar~", > with no effects on the running script > > o you may *delete* the script w/cygwin "rm" with no effects on > the running script and: > > * in the script's dir, "ls >/dev/null" will say in STDERR > > ls: foobar~: No such file or directory > > * cmd /c del foobar~ will err out with: > > Access is denied > > * as soon as the running script completes, "foobar~" will > be unlocked and will be deleted. Your earlier "rm" > command is finally "realized". > > I assume this is all by design- to emulate UNIX. AFAIK, Cygwin doesn't do anything special to emulate file locking in the absense of an appropriate flock() or fcntl() call. The above sounds like the normal Windows (or NTFS) "file-in-use" locking. I suspect the above may not work in Win9x or on FAT filesystems. FWIW, this can be reproduced with a non-network drive as well. Also, the above may have a side-effect of not closing the corresponding console window until the file is released... > I'm not a developer; so pls enlighten me if my statements above > are in accurate - I only ran one test. What kind of lock is put on > the script while it's running? > [snip] > Tom I suppose searching MSDN for "file locking" might be informative. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- 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/