From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5853e122 for ; Mon, 1 Jul 2019 16:53:40 +0000 (UTC) Received: (qmail 11546 invoked by alias); 1 Jul 2019 16:53:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44475 Received: (qmail 11687 invoked by uid 1010); 1 Jul 2019 16:53:35 -0000 X-Qmail-Scanner-Diagnostics: from mailout1.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25496. spamassassin: 3.4.2. Clear:RC:0(210.118.77.11):SA:0(-7.0/5.0):. Processed in 3.408135 secs); 01 Jul 2019 16:53:35 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.samsung.com designates 210.118.77.11 as permitted sender) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190701165256euoutp01eb7338d9d88a220a1fb3ae35ef2cde57~tVrP7TbtO1927219272euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1561999976; bh=z4ULItlfnLT58hWIOmbPATfWyREfmETvE+N3ONK57Q4=; h=Subject:From:To:Date:In-Reply-To:References:From; b=VSkN135e/80fwf1nlgO2P7egFHdiBWCMDEfLHYW1wo5SBUVMWoWzZVt+XBhnfocKN b8/p0GV1///3FCcXqhpOPotR1CAg5r//UUSvcWZc2KbgnV2IXxMxwCAcZF/+bhBAtR 4iXyvHmnnzP/uShqZK8aaouUDfI/1uh12f8TDo2c= X-AuditID: cbfec7f4-12dff70000001119-31-5d1a3a67a752 Message-ID: <1561999973.6006.21.camel@samsung.com> Subject: Re: <(...), >(...) and fds above 9 From: Peter Stephenson To: Zsh Hackers' List Date: Mon, 1 Jul 2019 17:52:53 +0100 In-Reply-To: <20190701162202.5o3cxahc75e2hucz@chaz.gmail.com> X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djP87oZVlKxBnfbWCwONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxv/JjWwFs7gr3vWcY2xgbOHsYuTkkBAwkTg0Yz8TiC0ksIJR YkVHdhcjF5DdxyRx9f5yRginl0mi69k9ZpiOm6umMUEkljNKXFrSxgZX9WfOPFYI5zSjxI9f Z6Gc84wSL2e3MIL08woYSRw+cgBslrCAtsTta8vA4mwChhJTN80Gsjk4RIDi7R/FQMIsAioS l5e9ZQOxOQVsJVbO38AEcYaGxIabx5ggRgpKnJz5hAXEZhaQl2jeOpsZZK+EwGM2ic6LW6Du dpE4d/4VlC0s8er4FnYIW0bi/875TBAN7YwSaya9ZodwehglNh29wwhRZS3Rd/si2HXMApoS 63fpQ4QdJba3HGMGCUsI8EnceCsIcQSfxKRt06HCvBIdbUIQ1WoSO5q2MkKEZSSerlGYwKg0 C8kHs5B8MAth1QJG5lWM4qmlxbnpqcVGeanlesWJucWleel6yfm5mxiBqeD0v+NfdjDu+pN0 iFGAg1GJh/cGl1SsEGtiWXFl7iFGCQ5mJRHe/SskY4V4UxIrq1KL8uOLSnNSiw8xSnOwKInz VjM8iBYSSE8sSc1OTS1ILYLJMnFwSjUwijy74vW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ace1cbc356faff441ad69f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190701100058epcas2p25e5f8dbd14d048fe2be1d831f3cf60ab X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190701100058epcas2p25e5f8dbd14d048fe2be1d831f3cf60ab References: <20190701100001.hbegs7zyu2auckhf@chaz.gmail.com> <1561975733.6006.2.camel@samsung.com> <1561994908.6006.19.camel@samsung.com> <20190701162202.5o3cxahc75e2hucz@chaz.gmail.com> On Mon, 2019-07-01 at 17:22 +0100, Stephane Chazelas wrote: > 2019-07-01 16:28:28 +0100, Peter Stephenson: > [...] > >  > > Looks like =(...) doesn't call closem() at all when > > forking, hence the difference in behaviour.  So > > =(...) is the odd one out. > [...] >  > But is there a good reason why we should close those fds? The shell has no idea whether you're happy to have lingering file descriptors when executing any old external software, so has to play safe in general.  It assumes you know what you're doing with file descriptors 0 to 7 and certain other types, and that others are dangerous. {fd}-opened file descriptors are marked FDT_EXTERNAL.  We could default to leaving those open on fork and document this.  This would then apply to file descriptors created with zsocket, which I presume you could think of as being in the same category. sysopen file descriptors are marked FDT_INTERNAL, which we'd certainly expect to close.  It looks like we make an exception if you use an explicit file descriptor number rather than ask for one to be assigned to a variable, I think because that's constrained to be 0 to 9.  So these could be changed to FDT_EXTERNAL, too, which would probably be more consistent. As I said, this is just based on needs and documentation rather than any definite logic. Probably =(...) should use closem() consisent with <(...), too. pws