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