subprocess.Popen 终止进程 超时后强制杀死
时间: 2023-10-27 13:20:46 浏览: 178
当使用subprocess.Popen启动一个子进程时,可以使用terminate()方法来停止子进程,也就是发送SIGTERM信号给子进程。而如果需要在超时后强制杀死子进程,可以使用kill()方法,该方法会发送SIGKILL信号给子进程,以确保其被立即终止。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [用python3 中的subprocess写一个简单的守护进程](https://blog.csdn.net/besmarterbestronger/article/details/94738845)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [使用python执行外部命令subprocess](https://blog.csdn.net/qq_27546717/article/details/115345386)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文