1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-25 14:20:53 +01:00

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.
This commit is contained in:
Barton E. Schaefer 2013-10-27 15:42:00 -07:00
parent 4748eff7d2
commit c98cbe25d2
3 changed files with 15 additions and 7 deletions

View file

@ -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) {