[英]How to kill a child process which it is running parallely
I have spawned many child 我生了很多孩子
var spawn = require('child_process').spawn,
newProcess1 = spawn('node', ['File1.js']),
newProcess2 = spawn('node', ['File2.js']),
newProcess3 = spawn('node', ['File3.js']);
which will run parallely.If newProcess1 fails then newProcess2 and newProcess3 must be stopped or killed if it has not started. 如果newProcess1失败,则newProcess2和newProcess3如果尚未启动,则必须停止或终止。
How can kill a child process? 如何杀死一个子进程?
newProcess1.on('close', function (code) {
console.log('child process ' + newProcess1.pid + ' exited with code ' + code);
newProcess2.kill();
newProcess3.kill();
});
http://nodejs.org/api/child_process.html http://nodejs.org/api/child_process.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.