On Wed, Sep 19, 2012 at 9:52 PM, PierreC <[email protected]> wrote: > All, > > Is there a way to stop node from terminating when data is piped to it? I > tried with -i with no luck. > > i.e. the following prints out the input data then stops, whereas I expect my > readline to kick in: > > echo "" | node test.js > > ``` > // test.js > var readline = require('readline'), > rl = readline.createInterface(process.stdin, process.stdout); > > rl.setPrompt('> ') > rl.prompt() > > rl.on('line', function(line) { > console.log('Line', line) > }).on('close', function() { > console.log('Closed'); > process.exit(0); > }); > > setTimeout(function() { > ;['stdin','stdout','stderr'].forEach(function (stream) { > console.log('Timeout %s is destroyed: %s', stream, > process[stream].destroyed) > }) > }, 100) > ``` > > Thoughts?
That could only work if node reopens stdin as /dev/tty when the pipe closes (which it doesn't). Are there scripting languages that let you do that? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
