aboutsummaryrefslogtreecommitdiff
path: root/libiberty/pex-win32.c
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2009-05-17 13:07:08 +0000
committerJulian Brown <jules@gcc.gnu.org>2009-05-17 13:07:08 +0000
commit965cc3c3aad4e7b106debe7c3870ef1d537aad8f (patch)
tree0b1606a2283a47163027424a2761a95097946f1f /libiberty/pex-win32.c
parent2f8cce28b83628caf64143b6e98cc09a61c0a619 (diff)
downloadgcc-965cc3c3aad4e7b106debe7c3870ef1d537aad8f.zip
gcc-965cc3c3aad4e7b106debe7c3870ef1d537aad8f.tar.gz
gcc-965cc3c3aad4e7b106debe7c3870ef1d537aad8f.tar.bz2
pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing standard handles (stdin, stdout, stderr) in parent.
libiberty/ * pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing standard handles (stdin, stdout, stderr) in parent. From-SVN: r147634
Diffstat (limited to 'libiberty/pex-win32.c')
-rw-r--r--libiberty/pex-win32.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 30ef435..91e0bc8 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -753,17 +753,20 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags,
original descriptors. */
orig_in = in;
in = _dup (orig_in);
- _close (orig_in);
+ if (orig_in != STDIN_FILENO)
+ _close (orig_in);
orig_out = out;
out = _dup (orig_out);
- _close (orig_out);
+ if (orig_out != STDOUT_FILENO)
+ _close (orig_out);
if (separate_stderr)
{
orig_err = errdes;
errdes = _dup (orig_err);
- _close (orig_err);
+ if (orig_err != STDERR_FILENO)
+ _close (orig_err);
}
stdin_handle = INVALID_HANDLE_VALUE;
@@ -844,11 +847,9 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags,
/* Close the standard input, standard output and standard error handles
in the parent. */
- if (in != STDIN_FILENO)
- _close (in);
- if (out != STDOUT_FILENO)
- _close (out);
- if (errdes != STDERR_FILENO)
+ _close (in);
+ _close (out);
+ if (separate_stderr)
_close (errdes);
return pid;