1
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.');
});
节点版本:0.10.17为什么子进程不能赶上 'SIGINT'
为什么子进程不能赶上 'SIGINT'? 但如果你单独运行节点child.js,它可以为ctrl + c终止cmd的信号。
是的,你是right.I想念那个line.But仍然无法work.can尝试 – hugo
我能够运行该程序,它表现出了SIGINT。每2秒后。 – user568109
也许是节点的版本,你能告诉你的节点版本和运行平台吗? – hugo