diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2011-10-26 18:48:13 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2011-10-26 18:48:13 +0000 |
commit | faa02346a8b23ff0c6694b616c92e93b8e76cd8b (patch) | |
tree | ecf0fa784803ed08e892eae486a7ffe9187eabf9 /Src | |
parent | 68d1c094db86d06e49cbb992fce51aa742418476 (diff) | |
download | zsh-faa02346a8b23ff0c6694b616c92e93b8e76cd8b.tar.gz zsh-faa02346a8b23ff0c6694b616c92e93b8e76cd8b.tar.xz zsh-faa02346a8b23ff0c6694b616c92e93b8e76cd8b.zip |
29844, 29845: remove bogus
error on closing fd's 0 to 9; update test
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c index 3d0731b3e..2c644e6b7 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2912,6 +2912,7 @@ execcmd(Estate state, int input, int output, int how, int last1) } addfd(forked, save, mfds, fn->fd1, fn->fd2, 1, fn->varid); } else { + int closed; if (fn->type != REDIR_HERESTR && xpandredir(fn, redir)) continue; if (errflag) { @@ -3002,11 +3003,20 @@ execcmd(Estate state, int input, int output, int how, int last1) * Note we may attempt to close an fd beyond max_zsh_fd: * OK as long as we never look in fdtable for it. */ - if (!forked && fn->fd1 < 10 && save[fn->fd1] == -2) + closed = 0; + if (!forked && fn->fd1 < 10 && save[fn->fd1] == -2) { save[fn->fd1] = movefd(fn->fd1); + if (save[fn->fd1] >= 0) { + /* + * The original fd is now closed, we don't need + * to do it below. + */ + closed = 1; + } + } if (fn->fd1 < 10) closemn(mfds, fn->fd1); - if (zclose(fn->fd1) < 0) { + if (!closed && zclose(fn->fd1) < 0) { zwarn("failed to close file descriptor %d: %e", fn->fd1, errno); } |