20198: fix TRAPEXIT.

This commit is contained in:
Peter Stephenson 2004-07-26 13:18:07 +00:00
parent 725616d600
commit 17e576782c
6 changed files with 25 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2004-07-26 Peter Stephenson <pws@csr.com>
* 20198: Src/exec.c, Src/signals.c, Test/C03traps.ztst,
Test/Makefile.in, Test/ztst.zsh: EXIT traps were freed before
being run. This isn't recommended by most programming text books.
2004-07-25 Bart Schaefer <schaefer@zsh.org>
* unposted: Doc/Zsh/contrib.yo: documentation for "zargs".

View file

@ -3495,7 +3495,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
memcpy(oldpipestats, pipestats, bytes);
}
starttrapscope();
if (!intrap)
starttrapscope();
tab = pparams;
if (!(flags & PM_UNDEFINED))
@ -3595,7 +3596,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
}
endtrapscope();
if (!intrap)
endtrapscope();
if (trapreturn < -1)
trapreturn++;

View file

@ -939,6 +939,10 @@ endtrapscope(void)
* with non-standard sigtrapped & sigfuncs values
*/
/* Are we already executing a trap? */
/**/
int intrap;
/**/
void
dotrapargs(int sig, int *sigtr, void *sigfn)
@ -949,9 +953,6 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
int obreaks = breaks;
int isfunc;
/* Are we already executing a trap? */
static int intrap;
/* if signal is being ignored or the trap function *
* is NULL, then return *
* *

View file

@ -57,6 +57,13 @@
>Function 1 going
>Function 2 going
# $ZTST_exe is relative to the parent directory.
# We ought to fix this in ztst.zsh...
cd ..
$ZTST_exe -fc 'TRAPEXIT() { print Exited.; }'
0:EXIT traps on a script
>Exited.
fn1() {
trap
trap 'print INT1' INT

View file

@ -46,7 +46,8 @@ check test:
$(MAKE) MODDIR=`pwd`/$(subdir)/Modules install.modules > /dev/null; \
fi
-for f in $(sdir)/$(TESTNUM)*.ztst; do \
$(dir_top)/Src/zsh +Z -f $(sdir)/ztst.zsh $$f; \
ZTST_exe=$(dir_top)/Src/zsh \
$(dir_top)/Src/zsh +Z -f $(sdir)/ztst.zsh $$f; \
done
rm -rf Modules .zcompdump

View file

@ -31,6 +31,8 @@ emulate -R zsh
# Set the module load path to correspond to this build of zsh.
# This Modules directory should have been created by "make check".
[[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
# Allow this to be passed down.
export MODULE_PATH
# We need to be able to save and restore the options used in the test.
# We use the $options variable of the parameter module for this.