From a860791d6f16406b78e7153f8eb438642f995da5 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 11 Jan 2017 06:38:25 -0800 Subject: [PATCH] Windows: avoid using pipe code for file redirection When Racket is run with stdout or stderr redirected to a file, then it must be treated as a regular file, otherwise flushing and position counting doesn't work right. Merge to v6.8 --- racket/src/racket/src/port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/racket/src/racket/src/port.c b/racket/src/racket/src/port.c index 783f371c57..7f5b1130a4 100644 --- a/racket/src/racket/src/port.c +++ b/racket/src/racket/src/port.c @@ -8450,7 +8450,10 @@ make_fd_output_port(intptr_t fd, Scheme_Object *name, int regfile, int win_textm #ifdef WINDOWS_FILE_HANDLES /* Character devices can't block output, right? */ - if (is_fd_terminal(fop->fd)) + if (!regfile && is_fd_terminal(fop->fd)) + regfile = 1; + /* It's important to not use pipe code for flushing to file handles: */ + if (!regfile && (GetFileType((HANDLE)fop->fd) == FILE_TYPE_DISK)) regfile = 1; /* The work thread is created on demand in fd_flush. */ #endif