Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Odd trap return status
- X-seq: zsh-workers 17250
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: Re: Odd trap return status
- Date: Wed, 29 May 2002 15:18:14 +0100
- In-reply-to: "Peter Stephenson"'s message of "Tue, 21 May 2002 16:19:55 BST." <21074.1021994395@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Peter Stephenson wrote:
> % inner() { trap 'return 1' EXIT; return 2; }
> % outer() { inner; print Not executed; return 3; }
> % outer; print $?
> 2
>
> I think that ought to be 1.
We save and restore a whole load of status for all traps, which isn't
necessary if they are fake traps which are never caused by signals.
This is a minimal patch for that.
However, are execsave() and execrestore() necessary now we queue signals
until some suitable point? There's a message from Zoltan (2751) some
time ago suggesting they shouldn't be any more (that was way before we'd
actually done anything about the problem). I'm too cowardly to remove
them for traps triggered by real signals without more thought.
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.20
diff -u -r1.20 signals.c
--- Src/signals.c 18 Jun 2001 09:29:48 -0000 1.20
+++ Src/signals.c 29 May 2002 14:10:58 -0000
@@ -945,7 +945,16 @@
*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 @@
trapret = trapreturn;
else if (errflag)
trapret = 1;
- execrestore();
+ if (sig != SIGEXIT && sig != SIGDEBUG)
+ execrestore();
lexrestore();
if (trapret > 0) {
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author