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: observation on cygwin file locking, just an FYI


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@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]