summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2017-04-27 18:56:18 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-04-27 18:56:18 +0100
commitd7110d8f01cae8c8d51c7abd0255f533cd8b8623 (patch)
tree238931229fcf7831c7ff5f41212f9626167fbb63 /Src/signals.c
parent48b0daf3d4972987873f1be00cc73d73734daf05 (diff)
downloadzsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.tar.gz
zsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.tar.xz
zsh-d7110d8f01cae8c8d51c7abd0255f533cd8b8623.zip
41012: Fix premature exit from nested function in EXIT trap.
Also add check so we don't delay an exit if we were already in
an EXIT trap for the main shell, as we should in that case leave
immediately.
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 68a7ae34d..cad40f4eb 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -55,6 +55,11 @@ mod_export Eprog siglists[VSIGCOUNT];
 /**/
 mod_export int nsigtrapped;
 
+/* Running an exit trap? */
+
+/**/
+int in_exit_trap;
+
 /*
  * Flag that exit trap has been set in POSIX mode.
  * The setter's expectation is therefore that it is run
@@ -1435,7 +1440,13 @@ dotrap(int sig)
 
     dont_queue_signals();
 
+    if (sig == SIGEXIT)
+	++in_exit_trap;
+
     dotrapargs(sig, sigtrapped+sig, funcprog);
 
+    if (sig == SIGEXIT)
+	--in_exit_trap;
+
     restore_queue_signals(q);
 }