From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7072 invoked from network); 27 Apr 2005 09:55:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 Apr 2005 09:55:22 -0000 Received: (qmail 21757 invoked from network); 27 Apr 2005 09:55:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Apr 2005 09:55:14 -0000 Received: (qmail 2833 invoked by alias); 27 Apr 2005 09:55:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21197 Received: (qmail 2821 invoked from network); 27 Apr 2005 09:55:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Apr 2005 09:55:10 -0000 Received: (qmail 21406 invoked from network); 27 Apr 2005 09:55:10 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 27 Apr 2005 09:54:58 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 27 Apr 2005 10:53:15 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 27 Apr 2005 10:55:28 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j3R9svtc029448 for ; Wed, 27 Apr 2005 10:54:57 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j3R9sujP029445 for ; Wed, 27 Apr 2005 10:54:56 +0100 Message-Id: <200504270954.j3R9sujP029445@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: localtraps In-reply-to: <1050427053638.ZM28743@candle.brasslantern.com> References: <20050425063521.GA17598@quark.hightek.org> <1050425163202.ZM25027@candle.brasslantern.com> <20050426030308.GA21501@quark.hightek.org> <200504261834.j3QIYHSa018951@news01.csr.com> <1050427053638.ZM28743@candle.brasslantern.com> Date: Wed, 27 Apr 2005 10:54:56 +0100 From: Peter Stephenson X-OriginalArrivalTime: 27 Apr 2005 09:55:28.0811 (UTC) FILETIME=[3E1567B0:01C54B0F] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 Bart Schaefer wrote: > So localtraps eventually worked in the sense that the inner trap was > removed, but the outer trap was never reset in the signal handler. OK, this one's fairly straightforward: starttrapscope() and endtrapscope() don't run inside traps. This is presumably to stop the exit trap from being triggered; I don't remember any conscious decision to prevent traps being restored on exit from other traps. What's more, the trap appears to be being saved, so we may have had a memory leak. Are we reasonably confident the other problems are specific to the NetBSD style of signal handling? I can't debug this, but we could probably introduce an option so that the signals were always queued and handled later (probably requiring more places where we need to check that queues should be run). Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.89 diff -u -r1.89 exec.c --- Src/exec.c 15 Apr 2005 10:40:14 -0000 1.89 +++ Src/exec.c 27 Apr 2005 09:47:39 -0000 @@ -3669,8 +3669,7 @@ memcpy(oldpipestats, pipestats, bytes); } - if (!intrap) - starttrapscope(); + starttrapscope(); tab = pparams; if (!(flags & PM_UNDEFINED)) @@ -3770,8 +3769,7 @@ opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS]; } - if (!intrap) - endtrapscope(); + endtrapscope(); if (trapreturn < -1) trapreturn++; Index: Src/signals.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/signals.c,v retrieving revision 1.36 diff -u -r1.36 signals.c --- Src/signals.c 6 Feb 2005 20:36:44 -0000 1.36 +++ Src/signals.c 27 Apr 2005 09:47:39 -0000 @@ -888,6 +888,10 @@ void starttrapscope(void) { + /* No special SIGEXIT behaviour inside another trap. */ + if (intrap) + return; + /* * SIGEXIT needs to be restored at the current locallevel, * so give it the next higher one. dosavetrap() is called @@ -917,8 +921,11 @@ /* * Remember the exit trap, but don't run it until * after all the other traps have been put back. + * Don't do this inside another trap. */ - if ((exittr = sigtrapped[SIGEXIT])) { + if (intrap) + exittr = 0; + else if ((exittr = sigtrapped[SIGEXIT])) { if (exittr & ZSIG_FUNC) { exitfn = removehashnode(shfunctab, "TRAPEXIT"); } else { -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************