You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using readline, the process.on('SIGINT', ...) is never triggered.
Is that planned, or perhaps a bug?
I searched and did not find other issues about it.
Hi @felipenmoura. Thanks for the report. Could you possibly give us a reduced test case with no external dependencies that shows this behavior so we can reproduce? Thanks!
Yep.
That's what is happening.
It's being discussed in Inquirer.js, here: SBoudrias/Inquirer.js#293 (comment)
Inquirer uses realine internally, therefore, who uses it cannot catch the SIGINT!
By the way, a test case:
process.on('SIGINT',function(){console.log('oh, you triggered it!');});constreadline=require('readline');constrl=readline.createInterface({input: process.stdin,output: process.stdout});rl.question('What do you think of Node.js? ',(answer)=>{console.log('Thank you for your valuable feedback, which was:\n',answer);rl.close();});
Activity
evanlucas commentedon Jan 19, 2016
Hi @felipenmoura. Thanks for the report. Could you possibly give us a reduced test case with no external dependencies that shows this behavior so we can reproduce? Thanks!
Fishrock123 commentedon Jan 19, 2016
@felipenmoura If you are trying to trigger by
ctrl+C, that won't work, because readline catches the keys?felipenmoura commentedon Jan 22, 2016
Yep.
That's what is happening.
It's being discussed in Inquirer.js, here: SBoudrias/Inquirer.js#293 (comment)
Inquirer uses realine internally, therefore, who uses it cannot catch the SIGINT!
By the way, a test case:
Fishrock123 commentedon Jan 22, 2016
So, readline is actually handles it, but only if it thinks it's input is a TTY: https://github.com/nodejs/node/blob/master/lib/readline.js#L693-L701
addaleax commentedon Jul 7, 2016
Adding the
SIGINTlistener on the readline instance itself instead ofprocessshould work?bnoordhuis commentedon Oct 7, 2016
This looks to have been solved for some time now so I'll go ahead and close the issue. Holler if it should be reopened.
Quit on cntl-c