1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

39870: ensure exit trap can always run

This commit is contained in:
Peter Stephenson 2016-11-08 13:02:24 +00:00
parent dfb2f3f3d2
commit a57977d01a
3 changed files with 23 additions and 0 deletions

View file

@ -5,6 +5,9 @@
2016-11-08 Peter Stephenson <p.stephenson@samsung.com>
* Src/builtin.c, Test/C03traps.ztst: ensure exit trap can always
run.
* unposted: Src/utils.c: follow up to 39867: don't need test
against zero any more.

View file

@ -5435,6 +5435,11 @@ zexit(int val, int from_where)
}
}
lastval = val;
/*
* Now we are committed to exiting any previous state
* is irrelevant. Ensure trap can run.
*/
errflag = intrap = 0;
if (sigtrapped[SIGEXIT])
dotrap(SIGEXIT);
callhookfunc("zshexit", NULL, 1, NULL);

View file

@ -626,6 +626,21 @@ F:Must be tested with a top-level script rather than source or function
>before-out
>before-in
if zmodload zsh/system 2>/dev/null; then
(
trap 'echo TERM; exit 2' TERM
trap 'echo EXIT' EXIT
kill -s TERM "$sysparams[pid]"
echo 'FATAL: we should never get here!' 1>&2
exit 1
)
else
ZTST_skip="zsh/system library not found."
fi
2:EXIT trap from TERM trap
>TERM
>EXIT
%clean
rm -f TRAPEXIT