看板 Python 關於我們 聯絡資訊
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嗎? 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.75.55.2 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1544515309.A.2E0.html ※ 編輯: phoenixcx (203.75.55.2), 12/11/2018 16:06:40
lemon651: 用子程序下指令殺父程序阿 12/11 16:58
lemon651: 跑第二個subprocess砍了父的 12/11 17:01
IAMPF: 試試 python3 monitor.py& ? 12/11 17:04
可以喔 ※ 編輯: phoenixcx (203.75.55.2), 12/11/2018 17:14:49