From 46ad2f5234164875cc65910dfc711666e4fa40af Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Thu, 23 Nov 2023 15:08:16 +0800 Subject: [PATCH] Check if the specified process ID exists --- common/command.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/command.py b/common/command.py index 7949b36..35dd271 100644 --- a/common/command.py +++ b/common/command.py @@ -194,3 +194,13 @@ class Command: else: print("An exception occurred when executing [{}]: {}".format(cmd, err)) return -1,cmd_result + + @staticmethod + def check_pid_exist(pid, flag): + check_pid_cmd = "ps -p {}".format(pid) + ret, res = Command.private_cmd_run(check_pid_cmd, flag) + if ret: + return False + else: + # 存在 + return True \ No newline at end of file -- Gitee