summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-11-08 13:02:24 +0000
committerPeter Stephenson <pws@zsh.org>2016-11-08 13:02:57 +0000
commita57977d01acc3b1b63aec1b79394ef7ffd052912 (patch)
tree31453161137d799ce25232a58bd0c116a9c2a621
parentdfb2f3f3d24f40012d129d3c205c9ca149f1bc1e (diff)
downloadzsh-a57977d01acc3b1b63aec1b79394ef7ffd052912.tar.gz
zsh-a57977d01acc3b1b63aec1b79394ef7ffd052912.zip
39870: ensure exit trap can always run
-rw-r--r--ChangeLog3
-rw-r--r--Src/builtin.c5
-rw-r--r--Test/C03traps.ztst15
3 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index edf3e78c9..e89b0c616 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/Src/builtin.c b/Src/builtin.c
index 6c9d05872..696971944 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -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);
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 74b83f33a..828a3d10f 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -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