about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2013-10-27 15:42:00 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2013-10-27 15:42:00 -0700
commitc98cbe25d2be2c8c552250e7e039a72e1f61887b (patch)
treef90413329d54c3627baac925951e5d2b0bcc08cd /Src/exec.c
parent4748eff7d2e97ff652f5d75d33b9aad12d7d917f (diff)
downloadzsh-c98cbe25d2be2c8c552250e7e039a72e1f61887b.tar.gz
zsh-c98cbe25d2be2c8c552250e7e039a72e1f61887b.tar.xz
zsh-c98cbe25d2be2c8c552250e7e039a72e1f61887b.zip
31919: fix deadlock when a shell builtin with a multio redirection is used on the left side of a pipeline
Make sure stdin/out/err file descriptors are closed for the multio copy
process, which means not re-using those descriptors after they are closed
and marked FDT_UNUSED in fdtable[].  For completeness, initialize their
fdtable[] state to FDT_EXTERNAL.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 99c7eaa6a..df915e152 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3123,7 +3123,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    int fd = fn->fd2;
 		    if(fd == -2)
 			fd = (fn->type == REDIR_MERGEOUT) ? coprocout : coprocin;
-		    fil = dup(fd);
+		    fil = movefd(dup(fd));
 		}
 		if (fil == -1) {
 		    char fdstr[4];
@@ -3151,7 +3151,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		else
 		    fil = clobber_open(fn);
 		if(fil != -1 && IS_ERROR_REDIR(fn->type))
-		    dfil = dup(fil);
+		    dfil = movefd(dup(fil));
 		else
 		    dfil = 0;
 		if (fil == -1 || dfil == -1) {