How to kill a tree of processes started by child_process? [closed]
Asked Answered
U

0

6

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?

Urethrectomy answered 13/3, 2012 at 13:7 Comment(1)
What operating system are you using? What function you are creating a child process? spawn or exec? child.pid contains pid of sudo or child process?Tuddor

© 2022 - 2024 — McMap. All rights reserved.