Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: pws-22: local traps addition



Couple of things I missed:  don't stick the old trap on the list if we're
not in a function, but do if we are in a function and all that does is
unset any existing trap.

--- Src/signals.c.st2	Fri Jun 18 15:38:35 1999
+++ Src/signals.c	Sun Jun 20 14:22:48 1999
@@ -668,7 +668,7 @@
      * one, to aid in removing this one.  However, if there's
      * already one at the current locallevel we just overwrite it.
      */
-    if (isset(LOCALTRAPS) &&
+    if (isset(LOCALTRAPS) && locallevel &&
 	(!sigtrapped[sig] || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT))) {
 	dosavetrap(sig, locallevel);
     } else if (sigfuncs[sig])
@@ -709,6 +709,19 @@
     if (sig == -1 || !(trapped = sigtrapped[sig]) ||
 	(jobbing && (sig == SIGTTOU || sig == SIGTSTP || sig == SIGTTIN))) {
         return;
+    }
+    if (isset(LOCALTRAPS) && locallevel &&
+	sigtrapped[sig] && locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)) {
+	/*
+	 * This calls unsettrap recursively to do any dirty work, so
+	 * make sure this bit doesn't happen:  a bit messy, but hard
+	 * to avoid.
+	 */
+	int oldlt = opts[LOCALTRAPS];
+	opts[LOCALTRAPS] = 0;
+	dosavetrap(sig, locallevel);
+	opts[LOCALTRAPS] = oldlt;
+	return;
     }
     sigtrapped[sig] = 0;
     if (sig == SIGINT && interact) {

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author