diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-12-01 21:43:36 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-12-12 12:03:36 +0100 |
commit | 874c28c9f5d14586ab71cd4af6899b11753caf25 (patch) | |
tree | 05dcde4cf1515eb023550ae9da8e5dbf5fe53fba | |
parent | 9dd07a91dba984c223730af30741565cb9bd88d5 (diff) | |
download | glibc-874c28c9f5d14586ab71cd4af6899b11753caf25.tar.gz glibc-874c28c9f5d14586ab71cd4af6899b11753caf25.tar.xz glibc-874c28c9f5d14586ab71cd4af6899b11753caf25.zip |
support: Close original descriptors in support_capture_subprocess
(cherry picked from commit 02cd5c1a8d033d7f91fea12a66bb44d1bbf85f76)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | support/support_capture_subprocess.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index a979f53811..2951523334 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-12-01 Florian Weimer <fweimer@redhat.com> + + * support/support_capture_subprocess.c + (support_capture_subprocess): Check that pipe descriptors have + expected values. Close original pipe descriptors in subprocess. + 2018-11-28 Florian Weimer <fweimer@redhat.com> * support/support.h (support_quote_string): Do not use str diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c index 6d2029e13b..93f6ea3102 100644 --- a/support/support_capture_subprocess.c +++ b/support/support_capture_subprocess.c @@ -59,8 +59,12 @@ support_capture_subprocess (void (*callback) (void *), void *closure) int stdout_pipe[2]; xpipe (stdout_pipe); + TEST_VERIFY (stdout_pipe[0] > STDERR_FILENO); + TEST_VERIFY (stdout_pipe[1] > STDERR_FILENO); int stderr_pipe[2]; xpipe (stderr_pipe); + TEST_VERIFY (stderr_pipe[0] > STDERR_FILENO); + TEST_VERIFY (stderr_pipe[1] > STDERR_FILENO); TEST_VERIFY (fflush (stdout) == 0); TEST_VERIFY (fflush (stderr) == 0); @@ -72,6 +76,8 @@ support_capture_subprocess (void (*callback) (void *), void *closure) xclose (stderr_pipe[0]); xdup2 (stdout_pipe[1], STDOUT_FILENO); xdup2 (stderr_pipe[1], STDERR_FILENO); + xclose (stdout_pipe[1]); + xclose (stderr_pipe[1]); callback (closure); _exit (0); } |