readline: pause stdin before turning off terminal raw mode
authorDaniel Chatfield <chatfielddaniel@gmail.com>
Tue, 30 Jul 2013 13:43:31 +0000 (14:43 +0100)
committerBert Belder <bertbelder@gmail.com>
Sat, 17 Aug 2013 13:35:09 +0000 (15:35 +0200)
commit5453619eb2a3bb3e5cae1c1379e3985c724e12c6
treec906c697c2dbfd6266f30b4ba2c49b3d318f8ade
parenta66d2400a09648dfe43902c1ab206ef4fd433db7
readline: pause stdin before turning off terminal raw mode

On windows, libuv will immediately make a `ReadConsole` call (in the
thread pool) when a 'flowing' `uv_tty_t` handle is switched to
line-buffered mode. That causes an immediate issue for some users,
since libuv can't cancel the `ReadConsole` operation on Windows 8 /
Server 2012 and up if the program switches back to raw mode later.

But even if this will be fixed in libuv at some point, it's better to
avoid the overhead of starting work in the thread pool and immediately
cancelling it afther that.

See also f34f1e3, where the same change is made for the opposite
flow, e.g. move `resume()` after `_setRawMode(true)`.

Fixes #5927

This is a backport of dfb0461 (see #5930) to the v0.10 branch.
lib/readline.js
test/simple/test-regress-GH-5927.js [new file with mode: 0644]