【问题标题】:Python kill defunct child process itselfPython杀死已失效的子进程本身
【发布时间】:2017-03-05 19:53:03
【问题描述】:

我正在使用多处理 python 库。
我创建新流程并执行我的工作。
完成工作后,我只是调用 exit(0),但进程处于“已失效”状态。 我尝试杀死'kill -9 PID','kill -18 PID'等,但我无法杀死子进程并保持父进程处于活动状态。

我该怎么办?这是我的python代码

'process.py'

def process(data, id):
    while isWorking:
        #work process and change isWorking to False

process = Process(target=process, args=(data,id))
process.start()

这是我的进程列表 (ps -al)

0 S  1001 19295 19291  0  80   0 - 45817 poll_s pts/3    00:00:09 python3
1 Z  1001 19339 19295  3  80   0 -     0 -      pts/3    00:00:58 pyth <defunct>

我想保持活跃的父进程(19295)并杀死子进程19339。
我该怎么办?

【问题讨论】:

    标签: python multiprocessing defunct


    【解决方案1】:

    试试这些命令:

    pkill -9 python
    
    ps -ef|grep python
    kill -9 <pid>
    

    【讨论】:

    • 不,我只想保持活动的父 python 进程,只杀死子 python 进程。
    猜你喜欢
    • 2010-12-08
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-27
    • 1970-01-01
    相关资源
    最近更新 更多