From f124756a03c89bd936fa9d41cf6ace406a2c1b4a Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 12 Apr 2006 18:42:01 +0000 Subject: merge from gcc --- libiberty/pex-win32.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libiberty/pex-win32.c') diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c index 3a75c5be00..046f393c6d 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 -- cgit v1.2.1