Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
signal trapping bug
- X-seq: zsh-workers 119
- From: P.Stephenson@xxxxxxxxxxxxx
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: signal trapping bug
- Date: Wed, 28 Jun 95 14:32:27 +0100
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@xxxxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author