I'have a process created with a spawn in nodejs with the option shell:true
so the process starts in a real shell. So when I try to kill this process with streamingTask.kill()
it's not working. Without the option shell:true
everything works fine.
This is how my code looks:
var options = {shell:true};
streamingTask = spawn('gst-launch-1.0',args,options);
...
streamingTask.kill()
So how can I kill this process now?
This doesn't work because you are killing the shell process itself, not the child process(es) spawned by the shell (gst-launch-1.0
in your case).
There's a package on npm called tree-kill that provides an easy one-line solution:
var kill = require('tree-kill');
kill(streamingTask.pid);