作者phoenixcx (曼秀雷敦)
看板Python
标题[问题] 有办法脱离父程序吗?
时间Tue Dec 11 16:01:46 2018
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://webptt.com/cn.aspx?n=bbs/Python/M.1544515309.A.2E0.html
※ 编辑: phoenixcx (203.75.55.2), 12/11/2018 16:06:40
1F:推 lemon651: 用子程序下指令杀父程序阿 12/11 16:58
2F:推 lemon651: 跑第二个subprocess砍了父的 12/11 17:01
3F:→ IAMPF: 试试 python3 monitor.py& ? 12/11 17:04
可以喔
※ 编辑: phoenixcx (203.75.55.2), 12/11/2018 17:14:49