How to close the child process Popen with shell = True

65 views Asked by At

This is the second day I've been puzzling over it. The situation is as follows. I start the bot with the command subprocess.Popen('stater.bat',cwd='F:/1/bot/', shell=True). Everything works, but I need the ability to shut down the bot. And that's the whole problem. I don't know how to turn the bot off. Another factor is that there will be 3+ of these bots running at once. And flexibility is needed, ie exactly what I need bot to turn off and on (this I can do). Help solve the problem with the closure of the child process.

Popen.kill(), but this not work. It's kill main bot, but children bot work

The idea is to get the PIDs of the child processes and kill them with a command, but how to get the PIDs of the child processes?

0

There are 0 answers