Answer the question
In order to leave comments, you need to log in
How to kill child processes after parent terminates?
Good afternoon, a sub process is created that spawns child processes, how to kill child processes after the sub process has already ended?
one could use psutil to take the pid of a sub process, find all of its children recursively, and kill it.
But if the sub process has ended, and it happened that the children (for example, the chrome driver) remained hanging, then psutil will no longer help, since the sub process does not exist and, accordingly, its children are not visible.
Yes, I completely forgot, all this is under windows
Answer the question
In order to leave comments, you need to log in
In general, I solved my problem myself, the wonderful standard atexit module, allows you to use psutil at the end of the process and kill all the garbage left after the process.
Look towards SIGNAL the operating system sends signals or events before closing, you can intercept them and call your code. In Windows, an application that does not respond to input, the system offers to kill after 15 seconds, so there is time
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question