summaryrefslogtreecommitdiff
path: root/libiberty/pex-win32.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2006-04-12 18:42:01 +0000
committerDJ Delorie <dj@delorie.com>2006-04-12 18:42:01 +0000
commitda31468982c83145468d83e8306d31ff927d747e (patch)
treeb6baa6c393bf68e547d1605b5d465fee7fd371fb /libiberty/pex-win32.c
parentce64b5c6620690a0534c5d83ce3a9f913aff7ccb (diff)
downloadgdb-da31468982c83145468d83e8306d31ff927d747e.tar.gz
merge from gcc
Diffstat (limited to 'libiberty/pex-win32.c')
-rw-r--r--libiberty/pex-win32.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 3a75c5be004..046f393c6d9 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -83,6 +83,7 @@ static int pex_win32_wait (struct pex_obj *, long, int *,
struct pex_time *, int, const char **, int *);
static int pex_win32_pipe (struct pex_obj *, int *, int);
static FILE *pex_win32_fdopenr (struct pex_obj *, int, int);
+static FILE *pex_win32_fdopenw (struct pex_obj *, int, int);
/* The list of functions we pass to the common routines. */
@@ -95,6 +96,7 @@ const struct pex_funcs funcs =
pex_win32_wait,
pex_win32_pipe,
pex_win32_fdopenr,
+ pex_win32_fdopenw,
NULL /* cleanup */
};
@@ -766,6 +768,18 @@ pex_win32_fdopenr (struct pex_obj *obj ATTRIBUTE_UNUSED, int fd,
return fdopen (fd, binary ? "rb" : "r");
}
+static FILE *
+pex_win32_fdopenw (struct pex_obj *obj ATTRIBUTE_UNUSED, int fd,
+ int binary)
+{
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ if (h == INVALID_HANDLE_VALUE)
+ return NULL;
+ if (! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0))
+ return NULL;
+ return fdopen (fd, binary ? "wb" : "w");
+}
+
#ifdef MAIN
#include <stdio.h>