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]

observation on cygwin file locking, just an FYI


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. 

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?

See below for my tests - you need
to watch the timestamps in the prompts and hop back and forth between
the bash sessions to follow it.  At 10:24:27 foobar is run on the
remote host; foobar is killed w/a ^C at 10:28:11.  The 300 line script foobar
just does something like "date;read ans" over and over.

--
regards,
Tom

# --------------------------------------------------------------------
# bash session on our file server w/hostname "mysrvrhost"
# --------------------------------------------------------------------
  # 10:24:18 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ echo [$PS1]; uname -a
  [# \t \d \w \h \u \n\s-\v $ ]
  CYGWIN_NT-5.0 mysrvrhost 1.3.20(0.73/3/2) 2003-02-08 12:10 i686 unknown unknown Cygwin
  # 10:24:21 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ seq 300|awk '{printf "date;read -p \"prompt no. %0d > \" ans\n",$1;}' >foobar         # 10:24:36 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ net file |grep foobar                                                                 24015085   I:\scm\public\tmp\foobar                ADM_TSR               0
  # 10:24:54 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ mv foobar foobar~
  # 10:25:22 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ 
  # 10:25:45 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ net file |grep foobar
  24015085   I:\scm\public\tmp\foobar                ADM_TSR               0
  # 10:25:56 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ rm -f foobar~
  # 10:26:13 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ ls -l >/dev/null
  ls: foobar~: No such file or directory
  # 10:26:24 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ xcacls foobar~
  i:\scm\public\tmp\foobar~
  Access is denied.
  # 10:26:40 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ cmd /c del foobar~
  i:\scm\public\tmp\foobar~
  Access is denied.
  # 10:26:57 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ ls -l >/dev/null
  # 10:28:35 Thu Apr 08 /public/tmp mysrvrhost adm_tsr
  -bash-2.05b $ cmd /c del foobar~
  Could Not Find i:\scm\public\tmp\foobar~

# --------------------------------------------------------------------
# bashsession on myclienthost
#   myclienthost sees "/public/tmp/foobar" as a network drive
#   it's shared out by mysrvrhost
# --------------------------------------------------------------------

  # 10:24:27 Thu Apr 08 /tmp myclienthost adm_tsr
  -bash-2.05b $ bash /public/tmp/foobar
  Thu Apr  8 10:24:43 CDT 2004
  prompt no. 1 >
  Thu Apr  8 10:25:26 CDT 2004
  prompt no. 2 >
  Thu Apr  8 10:25:37 CDT 2004
  prompt no. 3 >
  Thu Apr  8 10:25:37 CDT 2004
  prompt no. 4 >
  Thu Apr  8 10:25:40 CDT 2004
  prompt no. 5 >
  Thu Apr  8 10:27:04 CDT 2004
  prompt no. 6 >
  Thu Apr  8 10:27:04 CDT 2004
  prompt no. 7 >
  Thu Apr  8 10:27:04 CDT 2004
  prompt no. 8 >
  Thu Apr  8 10:27:05 CDT 2004
  prompt no. 9 >
  Thu Apr  8 10:27:08 CDT 2004
  prompt no. 10 >
  Thu Apr  8 10:28:04 CDT 2004
  prompt no. 11 > 
  <snip/did a ^C to abort script>
  # 10:28:11 Thu Apr 08 /tmp myclienthost adm_tsr
  -bash-2.05b $

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