-
Notifications
You must be signed in to change notification settings - Fork 295
Description
- Node.js Version: 9.7.1
- OS: linux
- Scope: runtime
- Module: child_process
I used child_process.fork
to generate some child processes and kill them with child.kill()
when the work is done.
My system always throws errors after running for a while. After some troubleshooting, I found that the longer my system is running, the more zombie processes are generated. The ppids of these processes are all 1, because child.kill()
does not release the process from memory, just stops the process.
I read the documentation and found that this is the mechanism of the Linux system. The killed process needs to call wait
/waitpid
to wait for the process to finish, but wait
/waitpid
does not exist in child_process and node.
I found a lot of information, but I didn't find a way for me.
I guess this is a wide-ranging problem. The solution should not be difficult. Have I missed something?