From a82fc30383b51940cc84823cad6284ef61a7927a Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Sun, 16 Sep 2018 22:47:17 +0300 Subject: [PATCH] tty: handle setRawMode errors PR-URL: https://github.com/nodejs/node/pull/22886 Refs: https://github.com/nodejs/node/issues/21773 Reviewed-By: Anna Henningsen Reviewed-By: Jeremiah Senkpiel Reviewed-By: Colin Ihrig --- lib/tty.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tty.js b/lib/tty.js index 62eb8719b114b9..4e78347c2d25ba 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -68,7 +68,11 @@ inherits(ReadStream, net.Socket); ReadStream.prototype.setRawMode = function(flag) { flag = !!flag; - this._handle.setRawMode(flag); + const err = this._handle.setRawMode(flag); + if (err) { + this.emit('error', errors.errnoException(err, 'setRawMode')); + return; + } this.isRaw = flag; };