[问题] 有办法脱离父程序吗?

楼主: phoenixcx (曼秀雷敦)   2018-12-11 16:01:46
import subprocess
from threading import Thread
def tmp():
subprocess.call("python3 monitor.py", shell=True)
return_dict[x]={'status':'success'}
t=Thread(target=tmp,)
t.start()
t.join(1)
print('end')
monitor.py执行成功,他是无限循环
end也print出来
但并没有脱离父程序
main.py与monitor.py的PID都有出来
有什么办法可以执行外部程式之后就不理他,脱离父程序
如果可行会造成defunct吗?
感谢!
作者: lemon651 (小明)   2018-12-11 16:58:00
用子程序下指令杀父程序阿跑第二个subprocess砍了父的
作者: IAMPF (PF)   2018-12-11 17:04:00
试试 python3 monitor.py& ?

Links booklink

Contact Us: admin [ a t ] ucptt.com