summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexis Campailla <alexis@janeasystems.com>2016-03-08 17:22:56 +0100
committerAlexis Campailla <alexis@janeasystems.com>2016-03-23 20:55:52 +0100
commit461138929498f31bd35bea61aa4375a2f56cceb7 (patch)
tree33a4b7563145fa15094e4693cccd61892247baf0 /lib
parentf429fe1b88db3463957058ec8975d3365fc3fefa (diff)
downloadandroid-node-v8-461138929498f31bd35bea61aa4375a2f56cceb7.tar.gz
android-node-v8-461138929498f31bd35bea61aa4375a2f56cceb7.tar.bz2
android-node-v8-461138929498f31bd35bea61aa4375a2f56cceb7.zip
tty: don't read from console stream upon creation
The tty.ReadStream constructor initializes this as a socket, which causes a read to be initiated. Even though during stdin initalization we call readStop shortly after, the read operation can consume keypress events from the system buffers. Fixes: https://github.com/nodejs/node/issues/5384 PR-URL: https://github.com/nodejs/node/pull/5776 Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com> Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tty.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/tty.js b/lib/tty.js
index 72efcd078b..ee6c0407f6 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -17,17 +17,23 @@ function ReadStream(fd, options) {
if (!(this instanceof ReadStream))
return new ReadStream(fd, options);
+ // pauseOnCreate to avoid reading from the sytem buffer
options = util._extend({
highWaterMark: 0,
readable: true,
writable: false,
- handle: new TTY(fd, true)
+ handle: new TTY(fd, true),
+ pauseOnCreate: true
}, options);
net.Socket.call(this, options);
this.isRaw = false;
this.isTTY = true;
+
+ // Let the stream resume automatically when 'data' event handlers
+ // are added, even though it was paused on creation
+ this._readableState.flowing = null;
}
inherits(ReadStream, net.Socket);