summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Src/exec.c8
-rw-r--r--Test/C03traps.ztst20
3 files changed, 33 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 891b58185..f34f5c5fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-05  Peter Stephenson  <pws@csr.com>
+
+	* 27947: Src/exec.c, Test/C03traps.ztst: fix some cases where we
+	should (probably) execute an EXIT trap but don't.
+
 2010-05-02  Frank Terbeck  <ft@bewatermyfriend.org>
 
 	* Simon Ruderich: 27813: Completion/Unix/Command/_git: Complete
@@ -13096,5 +13101,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4971 $
+* $Revision: 1.4972 $
 *****************************************************
diff --git a/Src/exec.c b/Src/exec.c
index 952d118c1..19afc4ca4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1299,6 +1299,12 @@ sublist_done:
     lineno = oldlineno;
     if (dont_change_job)
 	thisjob = cj;
+
+    if (exiting && sigtrapped[SIGEXIT]) {
+	dotrap(SIGEXIT);
+	/* Make sure this doesn't get executed again. */
+	sigtrapped[SIGEXIT] = 0;
+    }
 }
 
 /* Execute a pipeline.                                                *
@@ -1631,7 +1637,7 @@ execpline2(Estate state, wordcode pcode,
 		entersubsh(((how & Z_ASYNC) ? ESUB_ASYNC : 0)
 			   | ESUB_PGRP | ESUB_KEEPTRAP);
 		close(synch[1]);
-		execcmd(state, input, pipes[1], how, 0);
+		execcmd(state, input, pipes[1], how, 1);
 		_exit(lastval);
 	    }
 	} else {
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 7c4501413..853ae1aa0 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -350,6 +350,26 @@
 >trap
 >Working 0
 
+   { trap 'echo This subshell is exiting' EXIT; } | cat
+0: EXIT trap set in current shell at left of pipeline
+>This subshell is exiting  
+
+   ( trap 'echo This subshell is also exiting' EXIT; ) | cat
+0: EXIT trap set in subshell at left of pipeline
+>This subshell is also exiting  
+
+   ( trap 'echo Should only appear once at the end' EXIT
+     ( : trap reset here ) | cat
+     : trap not reset but not part of shell command list | cat
+     echo nothing after this should appear $( : trap reset here too)
+   )
+0: EXIT trap set in subshell reset in subsubshell
+>nothing after this should appear
+>Should only appear once at the end  
+
+   echo $( trap 'echo command substitution exited' EXIT )
+0: EXIT trap set in command substitution
+>command substitution exited  
 
 %clean