[英]How to kill a child process which it is running parallely
我生了很多孩子
var spawn = require('child_process').spawn,
newProcess1 = spawn('node', ['File1.js']),
newProcess2 = spawn('node', ['File2.js']),
newProcess3 = spawn('node', ['File3.js']);
如果newProcess1失敗,則newProcess2和newProcess3如果尚未啟動,則必須停止或終止。
如何殺死一個子進程?
newProcess1.on('close', function (code) {
console.log('child process ' + newProcess1.pid + ' exited with code ' + code);
newProcess2.kill();
newProcess3.kill();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.