about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-01-20 09:29:22 +0000
committerPeter Stephenson <pws@zsh.org>2015-01-20 09:29:22 +0000
commite6d964246700581fe22ea834b2ea12dd301e8c3d (patch)
tree7961ea0a86e1690136e53f0949feb60624d9c058 /Src
parentc6c9f5daf2e196e6ab7346dfbf5f5166a1d87f0c (diff)
downloadzsh-e6d964246700581fe22ea834b2ea12dd301e8c3d.tar.gz
zsh-e6d964246700581fe22ea834b2ea12dd301e8c3d.tar.xz
zsh-e6d964246700581fe22ea834b2ea12dd301e8c3d.zip
users/19751: remove error on failure to close file descriptor by number.
Keep it when closing file descriptor stored in a variable, i.e.
explicitly opened by the user.
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index f42fb2b9b..3b0e936b4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3203,7 +3203,12 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		}
 		if (fn->fd1 < 10)
 		    closemn(mfds, fn->fd1, REDIR_CLOSE);
-		if (!closed && zclose(fn->fd1) < 0) {
+		/*
+		 * Only report failures to close file descriptors
+		 * if they're under user control as we don't know
+		 * what the previous status of others was.
+		 */
+		if (!closed && zclose(fn->fd1) < 0 && fn->varid) {
 		    zwarn("failed to close file descriptor %d: %e",
 			  fn->fd1, errno);
 		}