需要首先了解shell=True和shell=False的區別和聯繫。
https://blog.csdn.net/xiaoyaozizai017/article/details/72794469
shell=True參數會讓subprocess.call接受字符串類型的變量作爲命令,並調用shell去執行這個字符串,當shell=False是,subprocess.call只接受數組變量作爲命令,並將數組的第一個元素作爲命令,剩下的全部作爲該命令的參數。
但是都沒解決我的問題啊,難過呀!
有大佬曉得的話,麻煩留個言,幫解決一下!
找到幾個比較好的方法:
雖然都沒有很好解決我的問題,希望對其他人有用吧。
(1)使用os.killpg(os.getpgid(p.pid), 9)
https://www.jianshu.com/p/39462b158af8
(2)將shell=True刪除,改爲列表形式使用
https://www.jianshu.com/p/a58491d1abf8
(3)subprocess.terminate()使用殺死子進程的方法處理
https://www.it610.com/article/5165972.htm
(4) python subprocess模塊開啓的子進程不隨父進程一同結束問題解決
wait()
https://blog.csdn.net/qq769747518/article/details/88970990
(5)python 借用psutil調用和kill子進程及孫進程
https://blog.csdn.net/weixin_34289744/article/details/91902573
(6)python 模塊psutil獲取進程信息
https://www.jianshu.com/p/d9a3372cc04d
以上方法都沒有解決我的問題
(7)同樣未解決的問題