I want open a program (ex: calculator) and keep tracking his process as the pid, name, etc. But, after calling the subprocess.Popen(), the process id is killed after few time.
So i want to initialize this program and get the process id and other informations and kill the process only if the user close the application (in this case, the calculator).
import subprocess
import psutil
process = subprocess.Popen('C:\Windows\System32\calc')
while psutil.pid_exists(process.pid):
print('Process running')
print('Done')