我是守夜人和节点的新手.js需要以下方面的帮助。作为守夜人设置的一部分,我在 before 函数中生成了一个子进程,并希望在 before 函数(拆解)中杀死该进程。我该怎么做。我不确定是否使用x.kill。
module.exports = {
before: function(done) {
spawn = require('child_process').spawn;
var x = spawn('./abc');
done();
},
after: function(done) {
done();
//how to kill x spawned in before function.
}
}
module.exports = {
before: function(done) {
spawn = require('child_process').spawn;
var x = spawn('./abc');
process.on('exit', function() {
x.kill('SIGKILL');}});
done();
},
after: function(done) {
proces.exit(0);
done();
}
}