From e6d964246700581fe22ea834b2ea12dd301e8c3d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 20 Jan 2015 09:29:22 +0000 Subject: 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. --- Src/exec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Src') 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); } -- cgit 1.4.1