From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1874 invoked from network); 20 Jun 1999 12:54:55 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 20 Jun 1999 12:54:55 -0000 Received: (qmail 3057 invoked by alias); 20 Jun 1999 12:54:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6725 Received: (qmail 3050 invoked from network); 20 Jun 1999 12:54:05 -0000 Message-Id: <9906201225.AA13796@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: pws-22: local traps addition Date: Sun, 20 Jun 1999 14:25:28 +0200 From: Peter Stephenson 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 Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy