Skip to content

Commit

Permalink
Merge pull request #184 from dsych/windows-sigint
Browse files Browse the repository at this point in the history
triggering sigint on windows
  • Loading branch information
gangstead committed Aug 25, 2017
2 parents 1c95d1d + 9e80863 commit 0ff93b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/prompt.js
Expand Up @@ -92,6 +92,16 @@ prompt.start = function (options) {
stdout.write('\n');
process.exit(1);
});
} else {
// listen for the "Ctrl+C" key combination and trigger process event.
// See https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
stdin.on('keypress', function(char, key) {
if (key && key.ctrl && key.name == 'c') {
stdout.write('\n');
process.emit("SIGINT");
process.exit(1);
}
});
}

prompt.emit('start');
Expand Down

0 comments on commit 0ff93b6

Please sign in to comment.