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:mime-version:content-type:date:from:to:subject :in-reply-to:references:message-id; q=dns; s=default; b=hBUxFBVX 20DMGjQUzHM0fBeh6qvMnxtEhaEj3JUVqH5ni6q+1RCLM/teu0AtIB/LjdM9NnO1 pgspBcUQFRziifIGMuWzyow+t5iT2Qxkro9ISpbHkyg6eMOTKXvPW7wTNuLSpcNa y4TNv0QoUNi5B4P/hFgJh51IRD4uC8ursgk= 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:mime-version:content-type:date:from:to:subject :in-reply-to:references:message-id; s=default; bh=S4atTjJUH1dsTW ylx0ufLG2BRWc=; b=FA1FSlu2HP7xFp8zDuU2HpFOhL+o2jS+Fs+5YgeogwWJlG 32GHQa+4kPtIT6KT8lZRm7/krAXibPjeoNwock90FrCeBGo/HhtQK2cxpaFyokJg eb40V1S6tXciPS6A35iwwJYiexUxYNZgEIVA4FzoONfx8DnHrxHD4XsKfRUZ4= 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=-2.6 required=5.0 tests=BAYES_00,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=pipe, socket, emulate, c.s X-HELO: lb3-smtp-cloud7.xs4all.net MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_e8233a59e192b3622c9d8208f8731238" Date: Tue, 22 Jan 2019 09:57:20 +0100 From: Houder To: cygwin AT cygwin DOT com Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux In-Reply-To: References: <0f030e809f063f5a5e64ff7a7a0c3227 AT xs4all DOT nl> <20190106201950 DOT GC4430 AT calimero DOT vinschen DOT de> Message-ID: <1c60402837d6510667357257b5e96e88@xs4all.nl> X-Sender: houder AT xs4all DOT nl User-Agent: XS4ALL Webmail X-IsSubscribed: yes --=_e8233a59e192b3622c9d8208f8731238 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 2019-01-22 09:50, Houder wrote: > On Sun, 6 Jan 2019 21:19:50, 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 >> > >> > 64-@@ cat /dev/fd/0 <<\EOF >> > > Hi >> > > EOF >> > cat: /dev/fd/0: No such file or directory >> > >> > fails on Cygwin; not on Linux. >> > >> > Also see: >> > >> > https://cygwin.com/ml/cygwin/2018-12/msg00028.html >> > ( Bash heredoc on FD 3 ) >> > >> > Based on the output of strace on Linux, I composed an STC, that duplicates >> > the steps taken by bash (and cat). >> >> This should work in the latest developer snapshot uploaded to >> https://cygwin.com/snapshots/ Please give it a try. >> >> Thanks, >> Corinna > > Nice! > > This solves: -i /dev/fd/N N< problem) > > Howver ... > (and I sure that I am not telling you anything new) > > it still not the same as Linux ... > > So, for the record only: and as another example, this STC succeeds on Linux ..., but fails on Cygwin. 64-@@ ./stca /dev/fd/0 < bla > EOF fd1 = 0 argv[1] = /dev/fd/0 fd2 = 3 id = writefd2, errno = 13, errstr = Permission denied 64-@@ ===== --=_e8233a59e192b3622c9d8208f8731238 Content-Transfer-Encoding: base64 Content-Type: text/x-c; name=stca.c Content-Disposition: attachment; filename=stca.c; size=6104 Ly8gZ2NjIC1XYWxsIC1vIHN0Y2Egc3RjYS5jCgojaW5jbHVkZSA8c3RkaW8u aD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNp bmNsdWRlIDxzdHJpbmc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Iik7ICAgICAgICBicmVhazsKICAgY2FzZSBTX0lGRElSOiAgcHJpbnRmKCJk aXJlY3RvcnlcbiIpOyAgICAgICAgICAgICAgIGJyZWFrOwogICBjYXNlIFNf SUZJRk86ICBwcmludGYoIkZJRk8vcGlwZVxuIik7ICAgICAgICAgICAgICAg YnJlYWs7CiAgIGNhc2UgU19JRkxOSzogIHByaW50Zigic3ltbGlua1xuIik7 ICAgICAgICAgICAgICAgICBicmVhazsKICAgY2FzZSBTX0lGUkVHOiAgcHJp bnRmKCJyZWd1bGFyIGZpbGVcbiIpOyAgICAgICAgICAgIGJyZWFrOwogICBj YXNlIFNfSUZTT0NLOiBwcmludGYoInNvY2tldFxuIik7ICAgICAgICAgICAg ICAgICAgYnJlYWs7CiAgIGRlZmF1bHQ6ICAgICAgIHByaW50ZigidW5rbm93 bj9cbiIpOyAgICAgICAgICAgICAgICBicmVhazsKICAgfQoKICAgcHJpbnRm KCJJLW5vZGUgbnVtYmVyOiAgICAgICAgICAgICVsZFxuIiwgKGxvbmcpc2It PnN0X2lubyk7CgojaWYgMAogICBwcmludGYoIk1vZGU6ICAgICAgICAgICAg ICAgICAgICAgJWxvIChvY3RhbClcbiIsICh1bnNpZ25lZCBsb25nKXNiLT5z dF9tb2RlKTsKI2Vsc2UKICAgcHJpbnRmKCJNb2RlOiAgICAgICAgICAgICAg ICAgICAgICVsbyAob2N0YWwpLCBscygxKS1zdHlsZTogJXNcbiIsCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodW5zaWduZWQgbG9u ZylzYi0+c3RfbW9kZSwgZmlsZVBlcm1TdHIoc2ItPnN0X21vZGUsIDApKTsK I2VuZGlmCgogICBwcmludGYoIkxpbmsgY291bnQ6ICAgICAgICAgICAgICAg JWxkXG4iLCAobG9uZylzYi0+c3RfbmxpbmspOwogICBwcmludGYoIk93bmVy c2hpcDogICAgICAgICAgICAgICAgVUlEPSVsZCAgIEdJRD0lbGRcbiIsIChs b25nKXNiLT5zdF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KSBpbgogICAgICAgcmV0dXJuaW5nIHNldC11c2VyLUlELCBz ZXQtZ3JvdXAtSUQsIGFuZCBzdGlja3kgYml0IGluZm9ybWF0aW9uIGluCiAg ICAgICB0aGUgdXNlci9ncm91cC9vdGhlciBleGVjdXRlIGZpZWxkcy4gVGhp cyBpcyBtYWRlIG1vcmUgY29tcGxleCBieQogICAgICAgdGhlIGZhY3QgdGhh dCB0aGUgY2FzZSBvZiB0aGUgY2hhcmFjdGVyIGRpc3BsYXllZCBmb3IgdGhp cyBiaXRzCiAgICAgICBkZXBlbmRzIG9uIHdoZXRoZXIgdGhlIGNvcnJlc3Bv bmRpbmcgZXhlY3V0ZSBiaXQgaXMgb24gb3Igb2ZmLiAqLwoKICAgIHNucHJp bnRmKHN0ciwgU1RSX1NJWkUsICIlYyVjJWMlYyVjJWMlYyVjJWMiLAogICAg ICAgIChwZXJtICYgU19JUlVTUikgPyAncicgOiAnLScsIChwZXJtICYgU19J V1VTUikgPyAndycgOiAnLScsCiAgICAgICAgKHBlcm0gJiBTX0lYVVNSKSA/ CiAgICAgICAgICAgICgoKHBlcm0gJiBTX0lTVUlEKSAmJiAoZmxhZ3MgJiBG UF9TUEVDSUFMKSkgPyAncycgOiAneCcpIDoKICAgICAgICAgICAgKCgocGVy bSAmIFNfSVNVSUQpICYmIChmbGFncyAmIEZQX1NQRUNJQUwpKSA/ICdTJyA6 ICctJyksCiAgICAgICAgKHBlcm0gJiBTX0lSR1JQKSA/ICdyJyA6ICctJywg KHBlcm0gJiBTX0lXR1JQKSA/ICd3JyA6ICctJywKICAgICAgICAocGVybSAm IFNfSVhHUlApID8KICAgICAgICAgICAgKCgocGVybSAmIFNfSVNHSUQpICYm IChmbGFncyAmIEZQX1NQRUNJQUwpKSA/ICdzJyA6ICd4JykgOgogICAgICAg ICAgICAoKChwZXJtICYgU19JU0dJRCkgJiYgKGZsYWdzICYgRlBfU1BFQ0lB TCkpID8gJ1MnIDogJy0nKSwKICAgICAgICAocGVybSAmIFNfSVJPVEgpID8g J3InIDogJy0nLCAocGVybSAmIFNfSVdPVEgpID8gJ3cnIDogJy0nLAogICAg ICAgIChwZXJtICYgU19JWE9USCkgPwogICAgICAgICAgICAoKChwZXJtICYg U19JU1ZUWCkgJiYgKGZsYWdzICYgRlBfU1BFQ0lBTCkpID8gJ3QnIDogJ3gn KSA6CiAgICAgICAgICAgICgoKHBlcm0gJiBTX0lTVlRYKSAmJiAoZmxhZ3Mg JiBGUF9TUEVDSUFMKSkgPyAnVCcgOiAnLScpKTsKCiAgICByZXR1cm4gc3Ry Owp9CiAgI2VuZGlmCiNlbmRpZgoKLy89PT09PQo= --=_e8233a59e192b3622c9d8208f8731238 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --=_e8233a59e192b3622c9d8208f8731238--