symlinks to unlinked but open files should work

Corinna Vinschen corinna-cygwin@cygwin.com
Sun Jul 3 11:14:00 GMT 2016


On Jul  1 22:40, Helmut Karlowski wrote:
> Cygwin seems to look up a symlink wrong:
> 
> When the target-file is unlinked while it is used by a process the file
> still exists and the symlink should point to that file.
> 
> Test:
> 
> ln -s out1 lout1
> exec >lout1
> rm out1
> [[ -w /dev/fd/1 ]] || echo /dev/fd/1 not writable 1>&2
> rm lout1
> 
> Only on cygwin it prints the message.

You don't even need a symlink.  This will show the same result:

  exec >out1
  rm out1
  [[ -w /dev/fd/1 ]] || echo /dev/fd/1 not writable 1>&2

In Cygwin we move a deleted but still open file out of the way (into
the trash) so the path is incorrect afterwards but even if we wouldn't
do that, the underlying problem can't be solved:

The problem is that a deleted file in Windows can't be opened anymore.
If you translate the above -w <file> into a libc call access
("/dev/fd/1", W_OK) or its Windows equivalent, that call will always
fail on a deleted file.  Same for open/CreateFile, etc.

Sorry, but off the top of my head I don't see a feasible workaround for
this problem.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160703/ea21c8e9/attachment.sig>


More information about the Cygwin mailing list