about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-05-29 14:28:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-05-29 14:28:05 +0000
commit1ca8378051227d70700d9f754d22e1bbde2924ad (patch)
tree8a350896e4ba41a9282fc6ebe84f9619f1dd0212
parent7898d5b1989c88e67f349ecfc088d86429932979 (diff)
downloadzsh-1ca8378051227d70700d9f754d22e1bbde2924ad.tar.gz
zsh-1ca8378051227d70700d9f754d22e1bbde2924ad.tar.xz
zsh-1ca8378051227d70700d9f754d22e1bbde2924ad.zip
17250: dont't execsave()/execrestore() around synchronous traps
-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) {