summaryrefslogtreecommitdiff
path: root/lib/tty.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tty.js')
-rw-r--r--lib/tty.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/tty.js b/lib/tty.js
index cf020f529d..144fc86b8e 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -40,11 +40,17 @@ function ReadStream(fd, options) {
if (fd >> 0 !== fd || fd < 0)
throw new errors.RangeError('ERR_INVALID_FD', fd);
+ const ctx = {};
+ const tty = new TTY(fd, true, ctx);
+ if (ctx.code !== undefined) {
+ throw new errors.SystemError(ctx);
+ }
+
options = util._extend({
highWaterMark: 0,
readable: true,
writable: false,
- handle: new TTY(fd, true)
+ handle: tty
}, options);
net.Socket.call(this, options);
@@ -69,8 +75,14 @@ function WriteStream(fd) {
if (fd >> 0 !== fd || fd < 0)
throw new errors.RangeError('ERR_INVALID_FD', fd);
+ const ctx = {};
+ const tty = new TTY(fd, false, ctx);
+ if (ctx.code !== undefined) {
+ throw new errors.SystemError(ctx);
+ }
+
net.Socket.call(this, {
- handle: new TTY(fd, false),
+ handle: tty,
readable: false,
writable: true
});