summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2013-12-20 23:03:46 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2013-12-20 23:03:46 -0800
commit9887fc3d7b4508bb21e419a8ce12be9c1ba37e4b (patch)
treeb47d012e680935591b12f55bc05df0d001340b41
parent58614f16693a741396840fbb3db0f9ba1e53cfcb (diff)
downloadzsh-9887fc3d7b4508bb21e419a8ce12be9c1ba37e4b.tar.gz
zsh-9887fc3d7b4508bb21e419a8ce12be9c1ba37e4b.tar.xz
zsh-9887fc3d7b4508bb21e419a8ce12be9c1ba37e4b.zip
32171: close pipe descriptor in parent when left side is a shell construct to
prevent deadlock

Also clean up ChangeLog entry that attributed 32119 to 32114
-rw-r--r--ChangeLog14
-rw-r--r--Src/exec.c4
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 4493d7598..1b84f2199 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-20  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 32171: Src/exec.c: fix leaked pipe descriptor that could
+	deadlock a pipeline from a complex shell construct or function
+	into an external command
+
 2013-12-20  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Config/version.mk, Etc/FAQ.yo, README: release 5.0.4.
@@ -31,10 +37,12 @@
 
 	* unposted: NEWS: add ZLE_PROMPT_INDENT.
 
+	* 32119: Src/Zle/zle_tricky.c: left square bracket completed in
+	command position is not part of a subscript expression
+
 	* Patrick Oscity + pws: 32114: Doc/Zsh/params.yo,
-	Src/Zle/zle_refresh.c, Src/Zle/zle_tricky.c: ZLE_RPROMPT_INDENT
-	allows you to make the right prompt flush if your terminal
-	supports it.
+	Src/Zle/zle_refresh.c: ZLE_RPROMPT_INDENT allows you to make the
+	right prompt flush if your terminal supports it.
 
 2013-12-16  Barton E. Schaefer  <schaefer@zsh.org>
 
diff --git a/Src/exec.c b/Src/exec.c
index dccdc2b0d..44800339f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1691,6 +1691,7 @@ execpline2(Estate state, wordcode pcode,
 	execcmd(state, input, output, how, last1 ? 1 : 2);
     else {
 	int old_list_pipe = list_pipe;
+	int subsh_close = -1;
 	Wordcode next = state->pc + (*state->pc), pc;
 	wordcode code;
 
@@ -1738,6 +1739,7 @@ execpline2(Estate state, wordcode pcode,
 	} else {
 	    /* otherwise just do the pipeline normally. */
 	    addfilelist(NULL, pipes[0]);
+	    subsh_close = pipes[0];
 	    execcmd(state, input, pipes[1], how, 0);
 	}
 	zclose(pipes[1]);
@@ -1750,6 +1752,8 @@ execpline2(Estate state, wordcode pcode,
 	execpline2(state, *state->pc++, how, pipes[0], output, last1);
 	list_pipe = old_list_pipe;
 	cmdpop();
+	if (subsh_close != pipes[0])
+	    zclose(pipes[0]);
     }
 }