father.js var spawn = require(‘child_process’).spawn; var child = spawn('node’,[‘child.js’]);
setInterval(function(){ child.kill(‘SIGINT’); },2000);
child.on('exit’,function(code,signal){
console.log('process exit ‘+code+’ '+signal);
});
child.js process.stdin.resume(); process.on('SIGINT’, function() { console.log(‘Got SIGINT. Press Control-D to exit.’); });
为什么子进程捕获不到父进程的信号? 如果单独运行node child.js,通过ctrl+c,却可以捕捉到