Skip to content

Commit

Permalink
signal handler for windows (CTRL-C to stop the server)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonetti authored and indexzero committed Mar 19, 2015
1 parent f328b20 commit 10f686a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions bin/http-server
Expand Up @@ -105,12 +105,16 @@ function listen(port) {
});
}

if (process.platform !== 'win32') {
//
// Signal handlers don't work on Windows.
//
process.on('SIGINT', function () {
log('http-server stopped.'.red);
process.exit();
if (process.platform === 'win32') {
require('readline').createInterface({
input: process.stdin,
output: process.stdout
}).on('SIGINT', function () {
process.emit('SIGINT');
});
}

process.on('SIGINT', function() {
log('http-server stopped.'.red);
process.exit();
});

0 comments on commit 10f686a

Please sign in to comment.