src: restore stdio on program exit
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.
Fixes: https://github.com/nodejs/node/issues/14752 CI: https://ci.nodejs.org/job/node-test-commit/14917/
Still pondering how to write a good test. The specific issue of #14752 (closed) is when fds 1 and 2 both refer to the write end of the same pipe but that's kind of hard to test without resorting to hacks and internals.