aboutsummaryrefslogtreecommitdiff
path: root/lib/tty.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-12-05 15:36:45 -0800
committerisaacs <i@izs.me>2011-12-05 16:47:11 -0800
commitcf20b6bf65bd037193d6e8b1b671c4659897861f (patch)
tree99dc0ef89117fdd90f2d8a3c33482451d0e18a3f /lib/tty.js
parent6f86b9cb70f4b4d9b214ef3533efbf389fa43824 (diff)
downloadandroid-node-v8-cf20b6bf65bd037193d6e8b1b671c4659897861f.tar.gz
android-node-v8-cf20b6bf65bd037193d6e8b1b671c4659897861f.tar.bz2
android-node-v8-cf20b6bf65bd037193d6e8b1b671c4659897861f.zip
Fix #2257 pause/resume semantics for stdin
This makes it so that the stdin TTY-wrap stream gets ref'ed on .resume() and unref'ed on .pause() The semantics of the names "pause" and "resume" are a bit weird, but the important thing is that this corrects an API change from 0.4 -> 0.6 which made it impossible to read from stdin multiple times, without knowing when it might end up being closed. If no one has it open, this lets the process die naturally. LGTM'd by @ry
Diffstat (limited to 'lib/tty.js')
-rw-r--r--lib/tty.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/tty.js b/lib/tty.js
index 78971dda31..32ba512d52 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -83,8 +83,19 @@ function ReadStream(fd) {
this.on('newListener', onNewListener);
}
inherits(ReadStream, net.Socket);
+
exports.ReadStream = ReadStream;
+ReadStream.prototype.pause = function() {
+ this._handle.unref();
+ return net.Socket.prototype.pause.call(this);
+};
+
+ReadStream.prototype.resume = function() {
+ this._handle.ref();
+ return net.Socket.prototype.resume.call(this);
+};
+
ReadStream.prototype.isTTY = true;