[問題] 有辦法脫離父程序嗎?

作者: 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