node.js - NodeJS: Can't kill spawn of gulp process -


i'd restart gulp on changes. can done placing following within gulpfile

spawn('gulp', [], { stdio: 'inherit'}); 

however, once gulp restarts in way, process no longer killed ctrl+c via terminal. if start gulp via terminal, can capture ctrl+c signal, can't if gulp started via spawn in gulpfile. how can capture 'sigint' spawn?

okay here's full story might encounter issue. have been reading, whenever want restart gulp within gulp use:

spawn('gulp', [], { stdio: 'inherit'}); process.exit(); 

i didn't mention process.exit() in question didn't expect affect usage of ctrl+c. indeed was, server expressjs one, whenever i'd use ctrl+c after gulp restarted within itself, port still in use error (error: listen eaddrinuse). obviously, node processes wasn't being closed. once removed line process.exit() code, able use ctrl+c , close processes. below useful bit of code in gulpfile , output in terminal related issue.

// gulpfile.js gulp.task('restart', function() {   server.close();   spawn('gulp', [], { stdio: 'inherit'});   process.exit(); // line needs removed });  process.on('sigint', function() {   settimeout(function() {     gutil.log(gutil.colors.red('successfully closed ' + process.pid));     process.exit(1);   }, 500); });  // console results: ^c[20:12:12] closed 67160 [20:12:12] closed 67151 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -