From 2c208c7743e240d155b2650f74c374ecab08644f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 27 Apr 2005 09:58:42 +0000 Subject: 21197: Fix LOCAL_TRAPS inside another trap --- Src/exec.c | 6 ++---- Src/signals.c | 9 ++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'Src') diff --git a/Src/exec.c b/Src/exec.c index f5feba50b..515a41f9b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3669,8 +3669,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)) @@ -3770,8 +3769,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 d1e6f22fe..e9571ef5b 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -888,6 +888,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 @@ -917,8 +921,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