This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] support: Close original descriptors in support_capture_subprocess
- From: Florian Weimer <fweimer at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Sat, 01 Dec 2018 12:23:30 +0100
- Subject: [PATCH] support: Close original descriptors in support_capture_subprocess
2018-12-01 Florian Weimer <fweimer@redhat.com>
* support/support_capture_subprocess.c
(support_capture_subprocess): Close original pipe descriptors in
subprocess.
diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
index 6d2029e13b..e1efcd52b0 100644
--- a/support/support_capture_subprocess.c
+++ b/support/support_capture_subprocess.c
@@ -72,6 +72,10 @@ support_capture_subprocess (void (*callback) (void *), void *closure)
xclose (stderr_pipe[0]);
xdup2 (stdout_pipe[1], STDOUT_FILENO);
xdup2 (stderr_pipe[1], STDERR_FILENO);
+ if (stdout_pipe[1] > STDERR_FILENO)
+ xclose (stdout_pipe[1]);
+ if (stderr_pipe[1] > STDERR_FILENO)
+ xclose (stderr_pipe[1]);
callback (closure);
_exit (0);
}