kripken/emscripten — pull request #1219 by inolen (2013-05-30 04:52:38+00:00)
Title: stdin read support for node

Added stdin read support for node. It's a bit wonky, as node doesn't allow you to perform a blocking read on stdin. Instead of the usual blocking until \n, it behaves as if stdin has been flagged with O_NONBLOCK. Perhaps it'd be nice to assert if you attempt to read on stdin and it hasn't been assigned O_NONBLOCK.

The return value of the default input implementation was also synchronized between node / the browser / shell - it now returns null when nothing was read as opposed to returning a default '\n'.

According to:
https://github.com/kripken/emscripten/commit/c1ec4646
it was intentional that cancel wouldn't trigger an EOF in the browser, however, sometime after that it was changed to this:
https://github.com/kripken/emscripten/blob/master/src/library.js#L519
so that it cancel would again act as an EOF, however the default value was still being set meaning shell's readline would get the default value instead of an EOF.

Needless to say, it's been synchronized for now.