From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 31262 invoked from network); 3 May 2020 17:31:06 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 May 2020 17:31:06 -0000 Received: (qmail 5406 invoked by alias); 3 May 2020 17:30:57 -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: 45771 Received: (qmail 4147 invoked by uid 1010); 3 May 2020 17:30:57 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-4.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25801. spamassassin: 3.4.4. Clear:RC:0(80.0.253.68):SA:0(-2.0/5.0):. Processed in 3.769176 secs); 03 May 2020 17:30:57 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.68 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=d6TbNyrE c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=IkcTkHD0fZMA:10 a=clzJoq8kXmIQtDbk0ikA:9 a=QEXdDO2ut3YA:10 Message-ID: Subject: Re: Feature request: ZSH_XTRACEFD variable From: Peter Stephenson To: zsh-workers@zsh.org Date: Sun, 03 May 2020 18:30:13 +0100 In-Reply-To: References: <20190518075514.hbygmb5dl5wz23h5@chaz.gmail.com> <20190520103444.qyih7lvoigvf3rfx@chaz.gmail.com> <1563722540.4311.24.camel@samsung.com> <1565710707.5633.11.camel@samsung.com> <309829031.4459446.1587391766024@mail2.virginmedia.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfKEeX60kc+OGYIUShyHfqv4UpJCKhLCe0M9tfbNKZG5FAQZyKB3rru1J3oEyheWXo7oEGVbL1FFMZEdDxj5xwF0cT5iqxLdLNuZCTYGt6q/Ox0jXxmwH t4upIVn3o4qclXbHEQKdGk49cIucQjp/v5GyDXAjTTZ9LNQ7pWIbCOYd On Sat, 2020-05-02 at 20:02 +0200, Timothée Mazzucotelli wrote: > I wrote such a test and noticed that file descriptors were being > closed each time ZSH_XTRACEFD was (re)assigned, even as a local > variable. So I removed the code lines closing the previous file > descriptor in xtracefdsetfn, and it seemed to work well. This re-introduces the file descriptor leak I was at pains to remove. It apparently works because the test isn't sensitive to the leak --- that's hard to fix in a standard way, i.e. with1out having some limit you can rely on on file descriptors being created. The key to this is the same as the point Daniel made: there needs to be special handling in parameter start/end scope for local variables. There are other variables that have some prior art for this --- e.g. SECONDS has special handling to make sure we get back the prevoius starting point for times. This variable might want something similar to make sure we remember the previous file descriptor rather than close it, but also make sure we close a local file descriptor on exit. It might be possible to detect in the parameter-specific functions that a new file descriptor is being called locally and the old one needs saving in a way it can be restored, but that might be harder than special code in the parmater scope hanling which should at least pick up all cases. As you'll see I haven't really thought this through at the moment... pws