node.js - In Sublime, why does my node process not exit naturally? -


when run node script in sublime 3 (as build system ... ctrl-b), if add listener stdin's data event, process stays running until killed. makes sense, since there's potentially still work do.

process.stdin.on('data', (d)=> {   // ... work `d` }); 

however, expected if removed listener data event, process naturally exit. doesn't!

// program never exits naturally.  function processdata(d) {   // ... work `d`, then...   process.stdin.removelistener('data', processdata); } process.stdin.on('data', processdata); 

even if remove event handler after adding it, process still sticks around...

function processdata() {}  process.stdin.on('data', processdata); process.stdin.removelistener('data', processdata); 

in exact case, use once() function instead of on(), doesn't clear me. missing? why stdin stream prevent process exiting, given has no listeners of kind?


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -