summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2009-05-17 13:12:28 +0000
committerJulian Brown <julian@codesourcery.com>2009-05-17 13:12:28 +0000
commitfef970b641e427b6a8f7159c58e009bf35bee9d6 (patch)
tree3d3cdd3a5cb85ce2d219c6f8ea271911b2d90058 /libiberty
parent1eda3b4ab168cd1ba592aab9f433412f72305449 (diff)
downloadbinutils-redhat-fef970b641e427b6a8f7159c58e009bf35bee9d6.tar.gz
libiberty/
* pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing standard handles (stdin, stdout, stderr) in parent.
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/pex-win32.c17
2 files changed, 14 insertions, 8 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 13c7fd5dd1..75e76d679d 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-17 Julian Brown <julian@codesourcery.com>
+
+ * pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing
+ standard handles (stdin, stdout, stderr) in parent.
+
2009-04-29 Julian Brown <julian@codesourcery.com>
* pex-win32.c (pex_win32_pipe): Add _O_NOINHERIT.
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 30ef435920..91e0bc882f 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;