diff options
author | Peter Stephenson <pws@zsh.org> | 2016-11-08 13:02:24 +0000 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2016-11-08 13:02:57 +0000 |
commit | a57977d01acc3b1b63aec1b79394ef7ffd052912 (patch) | |
tree | 31453161137d799ce25232a58bd0c116a9c2a621 | |
parent | dfb2f3f3d24f40012d129d3c205c9ca149f1bc1e (diff) | |
download | zsh-a57977d01acc3b1b63aec1b79394ef7ffd052912.tar.gz zsh-a57977d01acc3b1b63aec1b79394ef7ffd052912.tar.xz zsh-a57977d01acc3b1b63aec1b79394ef7ffd052912.zip |
39870: ensure exit trap can always run
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/builtin.c | 5 | ||||
-rw-r--r-- | Test/C03traps.ztst | 15 |
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 |