|
|
a57977 |
From 4f4fc498361ea9965fde31c36cf9971a92479e9f Mon Sep 17 00:00:00 2001
|
|
|
a57977 |
From: Peter Stephenson <pws@zsh.org>
|
|
|
a57977 |
Date: Tue, 20 Jan 2015 09:29:22 +0000
|
|
|
a57977 |
Subject: [PATCH 1/2] users/19751: remove error on failure to close file
|
|
|
a57977 |
descriptor by number.
|
|
|
a57977 |
|
|
|
a57977 |
Keep it when closing file descriptor stored in a variable, i.e.
|
|
|
a57977 |
explicitly opened by the user.
|
|
|
a57977 |
|
|
|
a57977 |
Upstream-commit: e6d964246700581fe22ea834b2ea12dd301e8c3d
|
|
|
a57977 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
a57977 |
---
|
|
|
a57977 |
Src/exec.c | 7 ++++++-
|
|
|
a57977 |
Test/A04redirect.ztst | 10 ++++++----
|
|
|
a57977 |
2 files changed, 12 insertions(+), 5 deletions(-)
|
|
|
a57977 |
|
|
|
a57977 |
diff --git a/Src/exec.c b/Src/exec.c
|
|
|
a57977 |
index 1a4ffe2..fcdc645 100644
|
|
|
a57977 |
--- a/Src/exec.c
|
|
|
a57977 |
+++ b/Src/exec.c
|
|
|
a57977 |
@@ -3075,7 +3075,12 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|
|
a57977 |
}
|
|
|
a57977 |
if (fn->fd1 < 10)
|
|
|
a57977 |
closemn(mfds, fn->fd1);
|
|
|
a57977 |
- if (!closed && zclose(fn->fd1) < 0) {
|
|
|
a57977 |
+ /*
|
|
|
a57977 |
+ * Only report failures to close file descriptors
|
|
|
a57977 |
+ * if they're under user control as we don't know
|
|
|
a57977 |
+ * what the previous status of others was.
|
|
|
a57977 |
+ */
|
|
|
a57977 |
+ if (!closed && zclose(fn->fd1) < 0 && fn->varid) {
|
|
|
a57977 |
zwarn("failed to close file descriptor %d: %e",
|
|
|
a57977 |
fn->fd1, errno);
|
|
|
a57977 |
}
|
|
|
a57977 |
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
|
|
|
a57977 |
index b8086e7..2f21b95 100644
|
|
|
a57977 |
--- a/Test/A04redirect.ztst
|
|
|
a57977 |
+++ b/Test/A04redirect.ztst
|
|
|
a57977 |
@@ -152,11 +152,13 @@
|
|
|
a57977 |
>hello
|
|
|
a57977 |
>goodbye
|
|
|
a57977 |
|
|
|
a57977 |
- ({ exec 3<&- } 2>/dev/null
|
|
|
a57977 |
- exec 3<&-
|
|
|
a57977 |
- read foo <&-)
|
|
|
a57977 |
+ (exec {varid}<&0
|
|
|
a57977 |
+ exec {varid}<&-
|
|
|
a57977 |
+ print About to close a second time >&2
|
|
|
a57977 |
+ read {varid}<&-)
|
|
|
a57977 |
1:'<&-' redirection
|
|
|
a57977 |
-*?\(eval\):*: failed to close file descriptor 3:*
|
|
|
a57977 |
+?About to close a second time
|
|
|
a57977 |
+*?\(eval\):*: failed to close file descriptor *
|
|
|
a57977 |
|
|
|
a57977 |
print foo >&-
|
|
|
a57977 |
0:'>&-' redirection
|
|
|
a57977 |
--
|
|
|
a57977 |
2.4.0
|
|
|
a57977 |
|
|
|
a57977 |
|
|
|
a57977 |
From 73ea1de52de3f078ef4e6f96ae5042cfe5e79730 Mon Sep 17 00:00:00 2001
|
|
|
a57977 |
From: Peter Stephenson <pws@zsh.org>
|
|
|
a57977 |
Date: Tue, 20 Jan 2015 11:53:42 +0000
|
|
|
a57977 |
Subject: [PATCH 2/2] users/19756: test for case of closing fd with no error
|
|
|
a57977 |
message
|
|
|
a57977 |
|
|
|
a57977 |
Upstream-commit: 638bfa93a009987e57bd7eaa8b2a1c1067a3652a
|
|
|
a57977 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
a57977 |
---
|
|
|
a57977 |
Test/A04redirect.ztst | 7 ++++++-
|
|
|
a57977 |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
a57977 |
|
|
|
a57977 |
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
|
|
|
a57977 |
index 2f21b95..70c210d 100644
|
|
|
a57977 |
--- a/Test/A04redirect.ztst
|
|
|
a57977 |
+++ b/Test/A04redirect.ztst
|
|
|
a57977 |
@@ -152,11 +152,16 @@
|
|
|
a57977 |
>hello
|
|
|
a57977 |
>goodbye
|
|
|
a57977 |
|
|
|
a57977 |
+ ({exec 3<&- } 2>/dev/null
|
|
|
a57977 |
+ exec 3<&-
|
|
|
a57977 |
+ read foo <&-)
|
|
|
a57977 |
+1:'<&-' redirection with numeric fd (no error message on failure)
|
|
|
a57977 |
+
|
|
|
a57977 |
(exec {varid}<&0
|
|
|
a57977 |
exec {varid}<&-
|
|
|
a57977 |
print About to close a second time >&2
|
|
|
a57977 |
read {varid}<&-)
|
|
|
a57977 |
-1:'<&-' redirection
|
|
|
a57977 |
+1:'<&-' redirection with fd in variable (error message on failure)
|
|
|
a57977 |
?About to close a second time
|
|
|
a57977 |
*?\(eval\):*: failed to close file descriptor *
|
|
|
a57977 |
|
|
|
a57977 |
--
|
|
|
a57977 |
2.4.0
|
|
|
a57977 |
|