我催生了很多孩子
var spawn = require('child_process').spawn,
newProcess1 = spawn('node', ['File1.js']),
newProcess2 = spawn('node', ['File2.js']),
newProcess3 = spawn('node', ['File3.js']);
将并行运行。如果newProcess1失败,则必须停止或杀死newProcess2和newProcess3(如果尚未启动)。
如何杀死子进程?
答案 0 :(得分:0)
newProcess1.on('close', function (code) {
console.log('child process ' + newProcess1.pid + ' exited with code ' + code);
newProcess2.kill();
newProcess3.kill();
});