我正在使用多处理 python 库。
我创建新流程并执行我的工作。
完成工作后,我只调用 exit(0),但进程处于“已失效”状态。我尝试杀死'kill -9 PID','kill -18 PID'等,但我无法杀死子进程并保持父进程处于活动状态。
我应该怎么做?这是我的python代码
'进程.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。
我应该怎么做?