From 5872705796d89d48bc4bf5f0b35678b0bd148ec2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 24 May 2019 16:11:19 +0200 Subject: src: restore stdio on program exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Record the state of the stdio file descriptors on start-up and restore them to that state on exit. This should prevent issues where node.js sometimes leaves stdio in raw or non-blocking mode. This is a reworked version of commit c2c9c0c3d3 from May 2018 that was reverted in commit 14dc17df38 from June 2018. The revert was a little light on details but I infer that the problem was caused by a missing call to `uv_tty_reset_mode()`. Apropos the NOLINT comments: cpplint doesn't understand do/while statements, it thinks they're while statements without a body. Fixes: https://github.com/nodejs/node/issues/14752 Fixes: https://github.com/nodejs/node/issues/21020 Original-PR-URL: https://github.com/nodejs/node/pull/20592 PR-URL: https://github.com/nodejs/node/pull/24260 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Refael Ackermann (רפאל פלחי) Reviewed-By: Anna Henningsen --- src/node_main_instance.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/node_main_instance.cc') diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 5c84dd64e6..f49b9fbb4d 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -145,7 +145,7 @@ int NodeMainInstance::Run() { env->set_can_call_into_js(false); env->stop_sub_worker_contexts(); - uv_tty_reset_mode(); + ResetStdio(); env->RunCleanup(); RunAtExit(env.get()); -- cgit v1.2.3