about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-03-30 16:51:54 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-03-30 16:51:54 +0000
commit261193a5b7da4ba36ca146424b000aca27c69235 (patch)
tree5a0d069181d7f37c421c4d9306a35c9dec2d5a41 /Src/signals.c
parent25c8b5525d3389f11fcaff673b54bc1d77cafd64 (diff)
downloadzsh-261193a5b7da4ba36ca146424b000aca27c69235.tar.gz
zsh-261193a5b7da4ba36ca146424b000aca27c69235.tar.xz
zsh-261193a5b7da4ba36ca146424b000aca27c69235.zip
Fix problem with traps not runing if shell exec'd final command
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 7ff4fca9d..d664f80c3 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -41,6 +41,11 @@ mod_export int sigtrapped[VSIGCOUNT];
 /**/
 mod_export Eprog sigfuncs[VSIGCOUNT];
 
+/* Total count of trapped signals */
+
+/**/
+mod_export int nsigtrapped;
+
 /* Variables used by signal queueing */
 
 /**/
@@ -716,6 +721,7 @@ settrap(int sig, Eprog l)
             sig != SIGCHLD)
             signal_ignore(sig);
     } else {
+	nsigtrapped++;
         sigtrapped[sig] = ZSIG_TRAPPED;
         if (sig && sig <= SIGCOUNT &&
 #ifdef SIGWINCH
@@ -773,6 +779,8 @@ removetrap(int sig)
 	unqueue_signals();
         return NULL;
     }
+    if (sigtrapped[sig] & ZSIG_TRAPPED)
+	nsigtrapped--;
     sigtrapped[sig] = 0;
     if (sig == SIGINT && interact) {
 	/* PWS 1995/05/16:  added test for interactive, also noholdintr() *
@@ -860,6 +868,8 @@ endtrapscope(void)
 	    exitfn = sigfuncs[SIGEXIT];
 	}
 	sigfuncs[SIGEXIT] = NULL;
+	if (sigtrapped[SIGEXIT] & ZSIG_TRAPPED)
+	    nsigtrapped--;
 	sigtrapped[SIGEXIT] = 0;
     }
 
@@ -878,6 +888,12 @@ endtrapscope(void)
 		dontsavetrap++;
 		settrap(sig, prog);
 		dontsavetrap--;
+		/*
+		 * counting of nsigtrapped should presumably be handled
+		 * in settrap...
+		 */
+		DPUTS((sigtrapped[sig] ^ st->flags) & ZSIG_TRAPPED,
+		      "BUG: settrap didn't restore correct ZSIG_TRAPPED");
 		if ((sigtrapped[sig] = st->flags) & ZSIG_FUNC)
 		    shfunctab->addnode(shfunctab, ((Shfunc)st->list)->nam,
 				       (Shfunc) st->list);