aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 8 insertions, 3 deletions
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)