Process Control with Python

I want to manage several subprocesses of the same type from python (I'm on Linux). I want to:

  • Run them.
  • Stop them.
  • Ask if they continue.

I can start processes using spawnl and get pid. Using this pid, I can stop it with kill. And I'm sure there is also a way to ask if it works with pid.

The problem is that if the following happens: I start the process, remember pid. The process ends, and I do not notice, and another completely different process begins to receive the same pid. I'm trying to kill my process, I'm killing quite another.

What is the best way to start and control processes in python? Thank you

+3
source share
1 answer

subprocess.Popen, , Popen. , , , , - pid! - , .

+7

Source: https://habr.com/ru/post/1748242/


All Articles