about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/signals.c14
2 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ed1718f39..17f9a5ffa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2002-05-29  Peter Stephenson  <pws@csr.com>
 
+	* 17250: Src/signals.c: don't execsave()/execrestore() around
+	traps which are executed synchronously, which caused unexpected
+	return statuses from `trap "return ..." EXIT'.
+
 	* 17249: Src/Modules/tcp.c: send output from `ztcp' or `ztcp -v'
 	to stdout, not the zle file descriptor.
 
diff --git a/Src/signals.c b/Src/signals.c
index fc8705f4f..8b1b9775c 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -945,7 +945,16 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
     *sigtr |= ZSIG_IGNORED;
 
     lexsave();
-    execsave();
+    if (sig != SIGEXIT && sig != SIGDEBUG) {
+	/*
+	 * SIGEXIT and SIGDEBUG are always run synchronously, so we don't
+	 * need to save and restore the state.
+	 *
+	 * Do we actually need this at all now we queue signals
+	 * for handling in places where they won't cause trouble?
+	 */
+	execsave();
+    }
     breaks = 0;
     runhookdef(BEFORETRAPHOOK, NULL);
     if (*sigtr & ZSIG_FUNC) {
@@ -972,7 +981,8 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	trapret = trapreturn;
     else if (errflag)
 	trapret = 1;
-    execrestore();
+    if (sig != SIGEXIT && sig != SIGDEBUG)
+	execrestore();
     lexrestore();
 
     if (trapret > 0) {