Skip to content

tty: add ref() so process.stdin.ref() etc. work

Rodrigo Muino Tomonari requested to merge github/fork/insightfuls/tty-ref into master
Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

tty

Description of change

tty.ReadStream and tty.WriteStream are documented to be net.Socket subclasses, so should support unref() and ref(), but only unref() worked. I ran into this problem when following advice at http://stackoverflow.com/questions/26004519/why-doesnt-my-node-js-process-terminate-once-all-listeners-have-been-removed to get Node to exit when I stop listening to stdin (which seems to be delayed until a newline is received otherwise). If I changed my mind and wanted to start listening again prior to exiting, it wasn't possible as ref() wasn't implemented (net.Socket.ref threw when trying to call tty_wrap.ref which didn't exist). This fixes it up trivially by implementing tty_wrap.ref().

Merge request reports

Loading