From 24aed1f2b1790f4ed6defac392230a6aa1f37dfd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 27 Apr 2005 10:03:14 +0000 Subject: 21197: Fix LOCAL_TRAPS inside another trap --- ChangeLog | 5 +++++ Src/exec.c | 6 ++---- Src/signals.c | 9 ++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f66e5fba3..6c0bfc0a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-04-27 Peter Stephenson + + * 21197: Src/exec.c, Src/signals.c: LOCAL_TRAPS didn't restore + a trap when modified inside another trap. + 2005-04-26 Peter Stephenson * 21195 (c.f. 21194 from Bart): Src/pattern.c, diff --git a/Src/exec.c b/Src/exec.c index 24355d275..2db264435 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3544,8 +3544,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) memcpy(oldpipestats, pipestats, bytes); } - if (!intrap) - starttrapscope(); + starttrapscope(); tab = pparams; if (!(flags & PM_UNDEFINED)) @@ -3645,8 +3644,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS]; } - if (!intrap) - endtrapscope(); + endtrapscope(); if (trapreturn < -1) trapreturn++; diff --git a/Src/signals.c b/Src/signals.c index e5225b6c5..8b70c880a 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -862,6 +862,10 @@ removetrap(int sig) 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 @@ -891,8 +895,11 @@ endtrapscope(void) /* * 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 { -- cgit 1.4.1