I have Node.js app that spawns processes using child_process.spawn(my_command)
. I use it to run commands like sudo my-app
.
When the sudo
process starts, it starts my-app
. So I end up with a tree of processes. sudo
at the top, my app, my server, etc. at the bottom.
From my node script, if I kill the process I started: my_process.kill("SIGTERM")
, it kills the sudo
process but not its children. My server keeps running.
Is there a way to kill the whole tree of processes?