From 979b21ba298edc64c88e2534b013076aa92ec975 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 19 Oct 2022 14:38:49 +0800
Subject: [PATCH 25/43] make sure kill pid not negative

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 src/cmd/isulad-shim/common.c                    | 2 +-
 src/daemon/modules/runtime/isula/isula_rt_ops.c | 4 ++--
 src/utils/cutils/utils.c                        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/cmd/isulad-shim/common.c b/src/cmd/isulad-shim/common.c
index 20e0963c..bb8464bb 100644
--- a/src/cmd/isulad-shim/common.c
+++ b/src/cmd/isulad-shim/common.c
@@ -175,7 +175,7 @@ int cmd_combined_output(const char *binary, const char *params[], void *output,
     ret = SHIM_OK;
 
 out:
-    if (ret != SHIM_OK && pid != 0) {
+    if (ret != SHIM_OK) {
         kill(pid, 9);
     }
 
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 1e4cb5aa..c9667ee5 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -361,7 +361,7 @@ static bool shim_alive(const char *workdir)
 
     file_read_int(fpid, &pid);
 
-    if (pid == 0) {
+    if (pid <= 0) {
         ERROR("failed read shim-pid file %s", fpid);
         return false;
     }
@@ -798,7 +798,7 @@ static void shim_kill_force(const char *workdir)
 
     file_read_int(fpid, &pid);
 
-    if (pid == 0) {
+    if (pid <= 0) {
         goto out;
     }
 
diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c
index eddfda5c..9f5deaf9 100644
--- a/src/utils/cutils/utils.c
+++ b/src/utils/cutils/utils.c
@@ -461,7 +461,7 @@ bool util_process_alive(pid_t pid, unsigned long long start_time)
     bool alive = true;
     proc_t *pid_info = NULL;
 
-    if (pid == 0) {
+    if (pid <= 0) {
         return false;
     }
 
-- 
2.25.1

