📜  python 在后台启动进程并获取 pid - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:29.936000             🧑  作者: Mango

代码示例1
from subprocess import Popen

# Subprocess Command
cmd = "python3 another_process.py"
p = Popen(cmd.split())
print("Process ID:", p.pid)

# Check the status of process
# poll() method returns 'None' if the process is running else returns the exit code
print(p.poll())