public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux
Date: Sun, 16 Dec 2018 20:31:00 -0000	[thread overview]
Message-ID: <20181216203118.GL28727@calimero.vinschen.de> (raw)
In-Reply-To: <20181216202847.GK28727@calimero.vinschen.de>

[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]

On Dec 16 21:28, Corinna Vinschen wrote:
> On Dec 16 17:31, Houder wrote:
> > L.S.,
> > 
> > /dev/fd/N not synonymous with file descriptor N; it is on Linux
> 
> Yes, it is.  Most of the time.  Try this:
> 
> $ echo foo | cat /dev/fd/0
> 
> The problem is that some of the concepts don't work as desired:
> 
> > 64-@@ cat /dev/fd/0 <<\EOF
> 
> If you observe what happens in tcsh in this situation you see that it
> doesn't even execute cat as long as you didn't type EOF.  What you type
> is written to a tmpfile:
> 
> $ ls -l /proc/5980/fd
> total 0
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 0 -> /tmp/sh.lVQq04
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 15 -> /dev/pty0
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 16 -> /dev/pty0
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 17 -> /dev/pty0
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 18 -> /dev/pty0
> lrwxrwxrwx 1 corinna vinschen 0 Dec 16 21:15 19 -> /dev/pty0
> 
> However, this tmpfile has been unlinked already, so it has been moved to the
> recycle bin:
> 
> $ ls -l /tmp/sh.lVQq04
> ls: /tmp/sh.lVQq04: No such file or directory
> 
> So the path in the fd subdir doesn't reflect the actual file path.
> 
> But after starting cat, cat tries to open /proc/self/fd/0 which
> is in fact the non-existing path /tmp/sh.lVQq04.  Bad luck.
> 
> In contrast to Linux the symlinks are not just faked symlinks with the
> underlying OS having direct access to the file descriptors.  The way
> it's implemented in Cygwin uses the actual file path resolution and then
> either works or fails as above.  I'm not sure how to fix that easily.
> I guess the fd/0 symlink would have to show the actual file path pointing
> to the recycle bin.  But that's often not what you want either since it
> hows a patch outside the POSIX namespace.
  shows a path

Sorry,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-12-16 20:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16 16:31 Houder
2018-12-16 20:28 ` Corinna Vinschen
2018-12-16 20:31   ` Corinna Vinschen [this message]
2018-12-16 21:36   ` Wayne Davison
2018-12-16 21:55     ` Corinna Vinschen
2018-12-17  4:30       ` Houder
2018-12-17  9:25         ` Corinna Vinschen
2018-12-17 11:26           ` Corinna Vinschen
2019-01-02 13:56             ` Houder
2018-12-17  3:41   ` Houder
2019-01-06 20:19 ` Corinna Vinschen
2019-01-22  8:50   ` Houder
2019-01-22  8:57     ` Houder
2019-01-22  9:06       ` Corinna Vinschen
2019-01-22  9:25         ` Houder
2019-01-22  9:42           ` Corinna Vinschen
2019-01-22 10:20             ` Houder
2019-01-22 10:39               ` Corinna Vinschen
2019-01-27 18:39                 ` Houder
2019-01-27 21:57                   ` Corinna Vinschen
2019-01-27 22:12                     ` Corinna Vinschen
2019-01-28 14:15                     ` Houder
2019-01-28 16:51                       ` Corinna Vinschen
2019-01-22  9:02     ` Corinna Vinschen
2019-01-22  9:07       ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181216203118.GL28727@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).