077c9d
commit 02cd5c1a8d033d7f91fea12a66bb44d1bbf85f76
077c9d
Author: Florian Weimer <fweimer@redhat.com>
077c9d
Date:   Sat Dec 1 21:43:36 2018 +0100
077c9d
077c9d
    support: Close original descriptors in support_capture_subprocess
077c9d
077c9d
diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
077c9d
index 6d2029e13bd6ae73..93f6ea310290000a 100644
077c9d
--- a/support/support_capture_subprocess.c
077c9d
+++ b/support/support_capture_subprocess.c
077c9d
@@ -59,8 +59,12 @@ support_capture_subprocess (void (*callback) (void *), void *closure)
077c9d
 
077c9d
   int stdout_pipe[2];
077c9d
   xpipe (stdout_pipe);
077c9d
+  TEST_VERIFY (stdout_pipe[0] > STDERR_FILENO);
077c9d
+  TEST_VERIFY (stdout_pipe[1] > STDERR_FILENO);
077c9d
   int stderr_pipe[2];
077c9d
   xpipe (stderr_pipe);
077c9d
+  TEST_VERIFY (stderr_pipe[0] > STDERR_FILENO);
077c9d
+  TEST_VERIFY (stderr_pipe[1] > STDERR_FILENO);
077c9d
 
077c9d
   TEST_VERIFY (fflush (stdout) == 0);
077c9d
   TEST_VERIFY (fflush (stderr) == 0);
077c9d
@@ -72,6 +76,8 @@ support_capture_subprocess (void (*callback) (void *), void *closure)
077c9d
       xclose (stderr_pipe[0]);
077c9d
       xdup2 (stdout_pipe[1], STDOUT_FILENO);
077c9d
       xdup2 (stderr_pipe[1], STDERR_FILENO);
077c9d
+      xclose (stdout_pipe[1]);
077c9d
+      xclose (stderr_pipe[1]);
077c9d
       callback (closure);
077c9d
       _exit (0);
077c9d
     }