mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
29844, 29845: remove bogus
error on closing fd's 0 to 9; update test
This commit is contained in:
parent
68d1c094db
commit
faa02346a8
3 changed files with 23 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2011-10-26 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
|
* 29844, 29845: Src/exec.c, Test/A04redirect.ztst: remove bogus
|
||||||
|
error on closing fd's 0 to 9; update test.
|
||||||
|
|
||||||
2011-10-26 Peter Stephenson <pws@csr.com>
|
2011-10-26 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 29865: Src/Modules/pcre.mdd: don't compile if no pcre-config.
|
* 29865: Src/Modules/pcre.mdd: don't compile if no pcre-config.
|
||||||
|
@ -15506,5 +15511,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5486 $
|
* $Revision: 1.5487 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
14
Src/exec.c
14
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);
|
addfd(forked, save, mfds, fn->fd1, fn->fd2, 1, fn->varid);
|
||||||
} else {
|
} else {
|
||||||
|
int closed;
|
||||||
if (fn->type != REDIR_HERESTR && xpandredir(fn, redir))
|
if (fn->type != REDIR_HERESTR && xpandredir(fn, redir))
|
||||||
continue;
|
continue;
|
||||||
if (errflag) {
|
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:
|
* Note we may attempt to close an fd beyond max_zsh_fd:
|
||||||
* OK as long as we never look in fdtable for it.
|
* 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);
|
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)
|
if (fn->fd1 < 10)
|
||||||
closemn(mfds, fn->fd1);
|
closemn(mfds, fn->fd1);
|
||||||
if (zclose(fn->fd1) < 0) {
|
if (!closed && zclose(fn->fd1) < 0) {
|
||||||
zwarn("failed to close file descriptor %d: %e",
|
zwarn("failed to close file descriptor %d: %e",
|
||||||
fn->fd1, errno);
|
fn->fd1, errno);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,11 +156,14 @@
|
||||||
read foo <&-)
|
read foo <&-)
|
||||||
1:'<&-' redirection
|
1:'<&-' redirection
|
||||||
?(eval):1: failed to close file descriptor 3: bad file descriptor
|
?(eval):1: failed to close file descriptor 3: bad file descriptor
|
||||||
?(eval):2: failed to close file descriptor 0: bad file descriptor
|
|
||||||
|
|
||||||
print foo >&-
|
print foo >&-
|
||||||
0:'>&-' redirection
|
0:'>&-' redirection
|
||||||
?(eval):1: failed to close file descriptor 1: bad file descriptor
|
|
||||||
|
(exec >&-
|
||||||
|
print foo)
|
||||||
|
0:'>&-' with attempt to use closed fd
|
||||||
|
?(eval):2: write error: bad file descriptor
|
||||||
|
|
||||||
fn() { local foo; read foo; print $foo; }
|
fn() { local foo; read foo; print $foo; }
|
||||||
coproc fn
|
coproc fn
|
||||||
|
|
Loading…
Reference in a new issue