Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Child Process on SIGINT #145

Open
meilechwieder opened this issue Aug 26, 2021 · 1 comment
Open

Stop Child Process on SIGINT #145

meilechwieder opened this issue Aug 26, 2021 · 1 comment

Comments

@meilechwieder
Copy link

meilechwieder commented Aug 26, 2021

When I press ctrl+c on the termianl while I run a script that uses croos-spawn, it does not stop the child process

Notice I use spawn.sync. But even without sync, It doesn't stop the child process

const spawn = require('cross-spawn');
process.on('SIGINT', function () {
  console.log('Caught interrupt signal');
  process.kill(ls.pid);
  process.exit()
});
var rl = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.on('SIGINT', function () {
  process.emit('SIGINT');
});
ls = spawn.sync('expo', ['publish'], { stdio: 'inherit' });

@cinderblock
Copy link

I wonder if this is the same problem that nodemon had to deal with in remy/nodemon#1025.

Specifically, using child_process.fork instead of child_process.spawn for node executables.

I'm using npm to run a package.json#script, which in turn uses nodemon with cross-env to launch the webpack cli. Something in that chain is leaving the webpack dev server running... I think this might be it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants