about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-09-24 10:12:51 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-09-24 10:12:51 +0000
commit11b073410867756f8fd04cc3b302ea8deef83433 (patch)
tree5a99c007bdd06afdf0f17e43ae5a890909690d34 /Src/exec.c
parentcd59ad72b6466bad25dc1fd9441d8ce30c741af0 (diff)
downloadzsh-11b073410867756f8fd04cc3b302ea8deef83433.tar.gz
zsh-11b073410867756f8fd04cc3b302ea8deef83433.tar.xz
zsh-11b073410867756f8fd04cc3b302ea8deef83433.zip
* Src/builtin.c, Src/exec.c: Unwind function calls before exiting
shell from exit command to allow EXIT traps to run.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 17ba376dd..c55494b96 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3429,6 +3429,22 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
     if (noreturnval)
 	lastval = oldlastval;
     popheap();
+
+    if (exit_pending) {
+	if (locallevel) {
+	    /* Still functions to return: force them to do so. */
+	    retflag = 1;
+	    breaks = loops;
+	} else {
+	    /*
+	     * All functions finished: time to exit the shell.
+	     * We already did the `stopmsg' test when the
+	     * exit command was handled.
+	     */
+	    stopmsg = 1;
+	    zexit(exit_pending >> 1, 0);
+	}
+    }
 }
 
 /* This finally executes a shell function and any function wrappers     *