zsh-workers
 help / color / mirror / code / Atom feed
From: P.Stephenson@swansea.ac.uk
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: signal trapping bug
Date: Wed, 28 Jun 95 14:32:27 +0100	[thread overview]
Message-ID: <7937.9506281332@pyro.swan.ac.uk> (raw)

Run the following function and type ^C during the sleep.

fn () { trap 'trap - EXIT INT' EXIT INT ; sleep 5 ; }

% fn
^C
zsh: 7433 abort (core dumped)  ./zsh

(You may require my recent signal fixes to see this.  They are not the
cause of the problem.)

I believe what's happening is that the function call code is saving
the old exit function and restoring it, even though the pointer is now
invalid because the same function was deleted by the copy in
sigfuncs[SIGEXIT].  As the function only gets used at that point if
it's changed, it makes more sense to set the trap to zero for the
duration of the function anyway.  This fixes things.

*** Src/exec.c.xfn	Tue Jun 27 15:57:36 1995
--- Src/exec.c	Wed Jun 28 13:58:23 1995
***************
*** 2277,2282 ****
--- 2277,2284 ----
      pushheap();
      xexittr = sigtrapped[SIGEXIT];
      xexitfn = sigfuncs[SIGEXIT];
+     sigtrapped[SIGEXIT] = 0;
+     sigfuncs[SIGEXIT] = 0;
      tab = pparams;
      oargv0 = argzero;
      oldzoptind = zoptind;
***************
*** 2337,2343 ****
  	opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE];
  	opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
      }
!     if (sigfuncs[SIGEXIT] && sigfuncs[SIGEXIT] != xexitfn) {
  	dotrap(SIGEXIT);
  	freestruct(sigfuncs[SIGEXIT]);
      }
--- 2339,2345 ----
  	opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE];
  	opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
      }
!     if (sigfuncs[SIGEXIT]) {
  	dotrap(SIGEXIT);
  	freestruct(sigfuncs[SIGEXIT]);
      }


-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.


                 reply	other threads:[~1995-06-28 13:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7937.9506281332@pyro.swan.ac.uk \
    --to=p.stephenson@swansea.ac.uk \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).