X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=mL3NwrUoFXbeCvVHWvI2HIs+C1iOOTEyZTnakZDz5DfRQ0jc4P5KK iI3ZZiTQx45/tZnBcYy4bZL4LJXOJ5K+8R4+sTWbsVC8YuAgA63TPniugsjfq3Dd r7ClvziFtxoQ3yib+ntkj0EVGjJSB2vLUZT47WmaocFJkmwm4EZ+h8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=XIaPijDZVjo2j3NA9PV/7phxHbw=; b=SOF/c1WcZuJiFB8C/q+bFf9cRa3x EZQT9g8YubUOIVUGZbpyTbCjAoeTvz1Uy5Ex3XzzmFT/0vnKM7aFhY267tyl5JRD wWqrh7lfDL4A80p+WwlvZzfykMq6mFjhPxq6nT2iEKC8BtzzVHjy10XYJqmD/apG hGumQ5hclHFDznc= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-100.9 required=5.0 tests=BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=echo, observe X-HELO: mout.kundenserver.de Date: Sun, 16 Dec 2018 21:28:47 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux Message-ID: <20181216202847.GK28727@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <0f030e809f063f5a5e64ff7a7a0c3227 AT xs4all DOT nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Qrgsu6vtpU/OV/zm" Content-Disposition: inline In-Reply-To: <0f030e809f063f5a5e64ff7a7a0c3227@xs4all.nl> User-Agent: Mutt/1.9.2 (2017-12-15) --Qrgsu6vtpU/OV/zm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Dec 16 17:31, Houder wrote: > L.S., >=20 > /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. Corinna --=20 Corinna Vinschen Cygwin Maintainer --Qrgsu6vtpU/OV/zm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlwWtX8ACgkQ9TYGna5E T6BVlxAAmX8sszeWC0MKgVePwsc6crxgIEFNBB3YOoNAhfCTpgcbbZQKqweN/BnL PaGwQfu9pCmCzpAA/rcIh9nvbNJwfIIHbGYr6f8rMvbrLQT/OSHHK0rW7D6IpHDY LR/jSXkWmWyiS8ziAAQz0cJHOmo7nzxxo+3RdRYEBHWnJTEajj90aj/ZGFYOD4P1 scUqqDTius3gF1rOkK+BbazjiwMnls4BnnE2XFGe8V+z8sXQFNwuQ7IcOLbeTZpX +N3U594dfec5ZU5/7wUYrfUnKdC2nRddUiK91fokd+V5k2UQpQNc1HylWR+sHhuT 6T2gj3ZnHbiCpprjX5eNSGYyrrWlSx5BcJUeha0u0N1d79St7LFhEVB75TwYsT0h GHE7Cjqiv+SaYsClFCTL6vtzSWxCwvNTgjOf9mRkfTIIj5o49BFxSngVegQ0emil Xv9bHd8ssYqXTQJPhmDkjj1gFnBkNnWTC3qxLPXK9ayzg2m8h421LXQFfhyhto+3 meGAtK7cKIRAjLWjhXiQICxU2gKOlQgpy3hkEVqKmbXPEnOCP4NQgfLKBwyVnCOK XjyL3idM/b4R3oG/L3qpAOevDl5LiIzEmcDtrJ6TRrN0tBo60SxtULC6s1nL0Gkc AAndPgM7fTEw+V3IPx5k8IrznSiAwJ5iDuAD1L/pTGT8As33Q68= =suDe -----END PGP SIGNATURE----- --Qrgsu6vtpU/OV/zm--