Permalink
Browse files

Merge pull request #184 from dsych/windows-sigint

triggering sigint on windows
  • Loading branch information...
2 parents 1c95d1d + 9e80863 commit 0ff93b6c1838fdf4b66b2eebdf9d3c57c65dd4c1 @gangstead gangstead committed Aug 25, 2017
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/prompt.js
View
@@ -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');

0 comments on commit 0ff93b6

Please sign in to comment.