From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124104 invoked by alias); 22 Jan 2019 09:42:04 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 123844 invoked by uid 89); 22 Jan 2019 09:42:03 -0000 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=resort, H*i:sk:1518985, H*f:sk:1518985, ATM X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Jan 2019 09:42:01 +0000 Received: from calimero.vinschen.de ([217.91.18.234]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MGi2e-1gyVsa1WJW-00DnIa for ; Tue, 22 Jan 2019 10:41:58 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 63250A80699; Tue, 22 Jan 2019 10:41:57 +0100 (CET) Date: Tue, 22 Jan 2019 09:42:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux Message-ID: <20190122094157.GN2802@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <0f030e809f063f5a5e64ff7a7a0c3227@xs4all.nl> <20190106201950.GC4430@calimero.vinschen.de> <1c60402837d6510667357257b5e96e88@xs4all.nl> <20190122090633.GK2802@calimero.vinschen.de> <151898514e462bd76cda8a227d4baa16@xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JkW1gnuWHDypiMFO" Content-Disposition: inline In-Reply-To: <151898514e462bd76cda8a227d4baa16@xs4all.nl> User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-01/txt/msg00171.txt.bz2 --JkW1gnuWHDypiMFO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2413 On Jan 22 10:25, Houder wrote: > On 2019-01-22 10:06, Corinna Vinschen wrote: > > On Jan 22 09:57, Houder wrote: > > > On 2019-01-22 09:50, Houder wrote: > > > > On Sun, 6 Jan 2019 21:19:50, Corinna Vinschen wrote: > > > > > This should work in the latest developer snapshot uploaded to > > > > > https://cygwin.com/snapshots/ Please give it a try. > > > > So, for the record only: > > >=20 > > > and as another example, this STC succeeds on Linux ..., but fails on > > > Cygwin. > > >=20 > > > 64-@@ ./stca /dev/fd/0 < > > > bla > > > > EOF > > > fd1 =3D 0 > > > argv[1] =3D /dev/fd/0 > > > fd2 =3D 3 > > > id =3D writefd2, errno =3D 13, errstr =3D Permission denied > > > 64-@@ > >=20 > > Not sure what you're testing. This is the result for me on both, > > Windows 8.1 and Windows 10 1809: >=20 > Curious! It fails (for me) on W7 ... It works for me just as well on W7: $ uname -a CYGWIN_NT-6.1 vmbert764 2.12.0(0.333/5/3) 2019-01-21 22:47 x86_64 Cygwin $ ./stca /dev/fd/0 < > Not sure what you're testing. >=20 > STC inherits a "read-only" open file descriptor from bash. On Linux > the file can be opened read-write (via procfs), because a new entry > is created in the open file table. >=20 > (opening the file read-write (via fdescfs) on FreeBSD would fail) >=20 > For this reason the output does not show what has been entered via > the here-doc. >=20 > In short, I was merely testing the semantics of Linux. Ah, ok. This is a bit of a problem on Windows. The code tries to reopen the file by handle. Under some circumstances(*) we can't reopen the file. In that case the code just tries to duplicate the handle. However, a duplicated file handle can't have more permissions than the original handle. So if it fails for you, it seems the reopen failed and the handle only got duplicated. In that case, you can't gain write perms if the original handle only got read perms. What the code fails to do is trying to open the file by name as a last resort. There was a (good?) reason I didn't implement that, but I don't remember ATM. Corinna (*) E.g., deleted files on systems older than Windows 10 1709, or files on filesystems not supporting the "reopen-by-handle" semantics. However, the latter case should work at least for non-deleted files --=20 Corinna Vinschen Cygwin Maintainer --JkW1gnuWHDypiMFO Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlxG5WUACgkQ9TYGna5E T6AAqg//XL/vJkSfU4NQ/ROXXuC6yM8YsnRBMx1cXhsaC1bT8s7xsEnkxPXyV/mq TEa1mJKzg76CBMBwHxmtIsDSkTUtSAp9QT/UPUYWtFcz1a6Ksa+4THVuQPM32cQw L/kjJHd4XBC9AWskrXWl5KDYBe6o4zamghk3PIUF4+tE67BmTlT/o6KlDP7iK30d b9PwaoVEBy9yuAYkLtwbna7+6/SfOY7nUn2cHZgRHNU/uA0l06VYv2x8U8IO3M0m nMX0EaQtzZIatmJlOlBq3J5EsjTjI0ZIFtS5CwtpS0gOLZUVBDkNbiDSPTba5w5w V0Dp2t+N+kDfApFDrVLC/j4AkboHKPfBAe7DehVD7DZKpUcgbrPikU13Fs5L27U2 QZjKfHburwjDQKAEO2k281rkQIliGOP3zhhqPBk4PAO9D0Yg455LrCSaZVvcUtfg StaDRbM2KkJwpwFbPpIt88Bn4mIS8RSHYyc95sibyndpNhJeH3ucY1mX5tVpExt4 hOLuJ2slXUqWS9kJjTbwKu0R61Sve1rfbv62BEjgNmByqmP+JrW84i7kQz1ZLwZ7 i4Y0H0h6MjVKDvS/V0RU9WaE2/Y2vDyYfpPJ1jCPUrcfHhJmaAVDXRwGfAAeGAyN tXHEdzUNCNnl/Yj6i/BC0vdmzINpLP/U6gEDPtOC0pG1w70ALTE= =BGa3 -----END PGP SIGNATURE----- --JkW1gnuWHDypiMFO--