From 8796ca44b4bc3bd28cdc7120fca910e4f37b0f45 Mon Sep 17 00:00:00 2001 From: Jiangzhou Li <605858621@qq.com> Date: Tue, 25 Mar 2025 15:46:08 +0800 Subject: [PATCH] fix: In the terminate_process method, adding wait after a failed kill operation helps reclaim the child process and prevents the creation of zombie processes --- gpustack/utils/process.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gpustack/utils/process.py b/gpustack/utils/process.py index 51daf26..bd222ee 100644 --- a/gpustack/utils/process.py +++ b/gpustack/utils/process.py @@ -117,5 +117,12 @@ def terminate_process(process): except psutil.TimeoutExpired: try: process.kill() + process.wait(timeout=3) except psutil.NoSuchProcess: pass + except psutil.TimeoutExpired: + logger.warning(f"Process {process.pid} failed to terminate after kill.") + except Exception as e: + logger.error(f"Error killing process {process.pid}: {e}") + except Exception as e: + logger.error(f"Error terminating process {process.pid}: {e}")