gpt4 book ai didi

linux - Linux下如何杀死一个进程及其所有子进程?

转载 作者:太空宇宙 更新时间:2023-11-04 04:42:29 24 4
gpt4 key购买 nike

user1    27913 41004  4 15:54 pts/202  00:00:02 python demo.py
user1 31916 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31917 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31918 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31919 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31920 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31921 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31922 27913 0 15:55 pts/202 00:00:00 python demo.py
user1 31923 27913 0 15:55 pts/202 00:00:00 python demo.py

有一个进程27913,我想杀死它及其所有子进程,我怎样才能让它工作?

update python script:

下面是我的demo.py

from concurrent.futures import ProcessPoolExecutor
import time

def foo(num):
time.sleep(0.5)
print(num)


if __name__ == "__main__":
while True:
with ProcessPoolExecutor(max_workers=8) as exe:
exe.map(foo, range(1,4))

最佳答案

通过进程ID杀死进程例如:使用此命令列出您的 python 文件 ps -A| grep python并终止进程:kill 27913

关于linux - Linux下如何杀死一个进程及其所有子进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57249614/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com