提交 8412889f 编写于 作者: D deveco_test

fix mac bug

Signed-off-by: Ndeveco_test <liguangjie1@huawei.com>
上级 90b5f7f3
......@@ -101,18 +101,32 @@ def is_proc_running(pid, name=None):
proc = subprocess.Popen(["C:\\Windows\\System32\\findstr", "%s" % pid],
stdin=proc_sub.stdout,
stdout=subprocess.PIPE, shell=False)
else:
elif platform.system() == "Linux":
# /bin/ps -ef | /bin/grep -v grep | /bin/grep -w pid
proc_sub = subprocess.Popen(["/bin/ps", "-ef"],
stdout=subprocess.PIPE,
shell=False)
proc_v_sub = subprocess.Popen(["/bin/grep", "-v", "grep"],
stdin=proc_sub.stdout,
stdout=subprocess.PIPE,
shell=False)
proc = subprocess.Popen(["/bin/grep", "-w", "%s" % pid],
stdin=proc_v_sub.stdout,
stdout=subprocess.PIPE, shell=False)
elif platform.system() == "Darwin":
# /bin/ps -ef | /bin/grep -v grep | /bin/grep -w pid
proc_sub = subprocess.Popen(["ps", "-ef"],
proc_sub = subprocess.Popen(["/bin/ps", "-ef"],
stdout=subprocess.PIPE,
shell=False)
proc_v_sub = subprocess.Popen(["grep", "-v", "grep"],
proc_v_sub = subprocess.Popen(["/usr/bin/grep", "-v", "grep"],
stdin=proc_sub.stdout,
stdout=subprocess.PIPE,
shell=False)
proc = subprocess.Popen(["grep", "-w", "%s" % pid],
proc = subprocess.Popen(["/usr/bin/grep", "-w", "%s" % pid],
stdin=proc_v_sub.stdout,
stdout=subprocess.PIPE, shell=False)
else:
raise Exception("Unknown system environment.")
(out, _) = proc.communicate()
out = get_decode(out).strip()
LOG.debug("check %s proc running output: %s", pid, out)
......
......@@ -117,9 +117,12 @@ def is_proc_running(pid, name=None):
if platform.system() == "Windows":
list_command = ["C:\\Windows\\System32\\tasklist"]
find_command = ["C:\\Windows\\System32\\findstr", "%s" % pid]
elif platform.system() == "Darwin":
list_command = ["/bin/ps", "-ef"]
find_command = ["/usr/bin/grep", "%s" % pid]
else:
list_command = ["ps", "-ef"]
find_command = ["grep", "%s" % pid]
list_command = ["/bin/ps", "-ef"]
find_command = ["/bin/grep", "%s" % pid]
proc = _get_find_proc(find_command, list_command)
(out, _) = proc.communicate()
out = get_decode(out).strip()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册