From 8b751f7eb7b05a0b27f52e2288a636fdd78e9ecb Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 31 Dec 2017 00:27:56 +0100 Subject: process: use more direct sync I/O for stdio This avoids routing writes through the full LibuvStreamWrap write machinery. In particular, it enables the next commit, because otherwise the callback passed to `_write()` would not be called synchronously for pipes on Windows (because the latter does not support `uv_try_write()`, even for blocking I/O). PR-URL: https://github.com/nodejs/node/pull/18019 Reviewed-By: Anatoli Papirovski Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/tty.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/tty.js') diff --git a/lib/tty.js b/lib/tty.js index 2a62fcb859..28f2a41184 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -24,6 +24,7 @@ const util = require('util'); const net = require('net'); const { TTY, isTTY } = process.binding('tty_wrap'); +const { makeSyncWrite } = require('internal/net'); const { inherits } = util; const errnoException = util._errnoException; const errors = require('internal/errors'); @@ -91,6 +92,8 @@ function WriteStream(fd) { // even though it was originally intended to change in v1.0.2 (Libuv 1.2.1). // Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671 this._handle.setBlocking(true); + this._writev = null; + this._write = makeSyncWrite(fd); var winSize = new Array(2); var err = this._handle.getWindowSize(winSize); -- cgit v1.2.3