From a75ad0f08b9ce337bc06a4be560488d3eacdea75 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 9 Oct 2011 21:14:52 +0200 Subject: Fixes for io noticed on PC, and also pc versions. --- io.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index df79499c..e423a436 100644 --- a/io.c +++ b/io.c @@ -444,9 +444,14 @@ remap_std_file(int oldfd) int newfd; int ret = -1; - close(oldfd); - newfd = open("/dev/null", O_RDWR); - if (newfd >= 0 && newfd != oldfd) { + /* + * Give OS-specific routines in gawkmisc.c chance to interpret + * "/dev/null" as appropriate for their platforms. + */ + newfd = os_devopen("/dev/null", O_RDWR); + if (newfd == INVALID_HANDLE) + newfd = open("/dev/null", O_RDWR); + if (newfd >= 0) { /* dup2() will close oldfd for us first. */ ret = dup2(newfd, oldfd); if (ret == 0) -- cgit v1.2.3