From e2b9254ae954762a63eea7ec656dffbccd811b2d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 21 Sep 2019 17:44:03 -0700 Subject: [PATCH] Remove node stdin tty hack (#9476) Fixes #6505 --- src/library_tty.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/library_tty.js b/src/library_tty.js index 28b881adde37..3c512d04fd39 100644 --- a/src/library_tty.js +++ b/src/library_tty.js @@ -110,20 +110,8 @@ mergeInto(LibraryManager.library, { var buf = Buffer.alloc ? Buffer.alloc(BUFSIZE) : new Buffer(BUFSIZE); var bytesRead = 0; - var isPosixPlatform = (process.platform != 'win32'); // Node doesn't offer a direct check, so test by exclusion - - var fd = process.stdin.fd; - if (isPosixPlatform) { - // Linux and Mac cannot use process.stdin.fd (which isn't set up as sync) - var usingDevice = false; - try { - fd = fs.openSync('/dev/stdin', 'r'); - usingDevice = true; - } catch (e) {} - } - try { - bytesRead = fs.readSync(fd, buf, 0, BUFSIZE, null); + bytesRead = fs.readSync(process.stdin.fd, buf, 0, BUFSIZE, null); } catch(e) { // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes, // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0. @@ -131,7 +119,6 @@ mergeInto(LibraryManager.library, { else throw e; } - if (usingDevice) { fs.closeSync(fd); } if (bytesRead > 0) { result = buf.slice(0, bytesRead).toString('utf-8'); } else {