windows: set stdio streams to binary mode
authorIgor Zinkovsky <igorzi@microsoft.com>
Tue, 2 Aug 2011 01:21:38 +0000 (18:21 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 2 Aug 2011 01:30:13 +0000 (18:30 -0700)
src/node_stdio_win32.cc

index f76c71b..489508c 100644 (file)
@@ -25,6 +25,7 @@
 #include <v8.h>
 
 #include <errno.h>
+#include <fcntl.h>
 #include <io.h>
 
 #include <platform_win32.h>
@@ -663,6 +664,11 @@ void Stdio::Initialize(v8::Handle<v8::Object> target) {
   uv_async_init(&tty_avail_notifier, tty_poll);
   uv_unref();
 
+  /* Set stdio streams to binary mode. */
+  _setmode(_fileno(stdin), _O_BINARY);
+  _setmode(_fileno(stdout), _O_BINARY);
+  _setmode(_fileno(stderr), _O_BINARY);
+
   name_symbol = NODE_PSYMBOL("name");
   shift_symbol = NODE_PSYMBOL("shift");
   ctrl_symbol = NODE_PSYMBOL("ctrl");