Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: localtraps
- X-seq: zsh-workers 21197
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: localtraps
- Date: Wed, 27 Apr 2005 10:54:56 +0100
- In-reply-to: <1050427053638.ZM28743@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050425063521.GA17598@xxxxxxxxxxxxxxxxx> <1050425163202.ZM25027@xxxxxxxxxxxxxxxxxxxxxxx> <20050426030308.GA21501@xxxxxxxxxxxxxxxxx> <200504261834.j3QIYHSa018951@xxxxxxxxxxxxxx> <1050427053638.ZM28743@xxxxxxxxxxxxxxxxxxxxxxx>
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 <pws@xxxxxxx> 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.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author