From 8d5a75e9438282df55e1157df28e6b6791b1e198 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Thu, 23 Nov 2023 15:09:14 +0800 Subject: [PATCH] Check if each process in the given process ID list exists --- common/command.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/command.py b/common/command.py index 35dd271..93707b1 100644 --- a/common/command.py +++ b/common/command.py @@ -203,4 +203,21 @@ class Command: return False else: # 存在 - return True \ No newline at end of file + return True + + @staticmethod + def check_pid_list(pid_list, flag): + pid = pid_list.split(',') + for item in pid: + if item == '-1' and len(pid) != 1: + if flag: + Logger().error("pid list contains -1, but length not 1") + return False + if item != '-1' and not item.isdigit(): + if flag: + Logger().error("process id should be digit number") + return False + if item != '-1': + return Command.check_pid_exist(item, flag) + return True + # end add for hotspot collection \ No newline at end of file -- Gitee