zsh-workers
 help / color / mirror / code / Atom feed
* signal trapping bug
@ 1995-06-28 13:32 P.Stephenson
  0 siblings, 0 replies; only message in thread
From: P.Stephenson @ 1995-06-28 13:32 UTC (permalink / raw)
  To: Zsh hackers list

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-06-28 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-28 13:32 signal trapping bug P.Stephenson

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).