Skip to content

Commit 0ff93b6

Browse files
authored
Merge pull request #184 from dsych/windows-sigint
triggering sigint on windows
2 parents 1c95d1d + 9e80863 commit 0ff93b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/prompt.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ prompt.start = function (options) {
9292
stdout.write('\n');
9393
process.exit(1);
9494
});
95+
} else {
96+
// listen for the "Ctrl+C" key combination and trigger process event.
97+
// See https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
98+
stdin.on('keypress', function(char, key) {
99+
if (key && key.ctrl && key.name == 'c') {
100+
stdout.write('\n');
101+
process.emit("SIGINT");
102+
process.exit(1);
103+
}
104+
});
95105
}
96106

97107
prompt.emit('start');

0 commit comments

Comments
 (0)