I use the following code to create child process, the process is working as expected, what I want to do now is at the end of the process kill it , I try with the last then (which if I put BP it stops there after the process done) my question is how to kill it properly and avoid this error.
getCmd provide the command to run and this is working as expected
var childProcess = Promise.promisify(require('child_process').exec);
....
.then(getCmd)
.then(childProcess)
.spread(function (stdout, stderr) {
console.log(stdout, stderr);
return stdout;
}).then(function(){
childProcess.kill()
})
when the line childProcess.kill()
is executed I got error :
[TypeError: undefined is not a function]
How to overcome this issue and kill the process at the end