mirror of
https://github.com/openharmony/test_xdevice.git
synced 2026-07-19 10:15:51 -04:00
@@ -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(["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(["/bin/grep", "-v", "grep"],
|
||||
stdin=proc_sub.stdout,
|
||||
stdout=subprocess.PIPE,
|
||||
shell=False)
|
||||
proc = subprocess.Popen(["grep", "-w", "%s" % pid],
|
||||
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(["/bin/ps", "-ef"],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=False)
|
||||
proc_v_sub = subprocess.Popen(["/usr/bin/grep", "-v", "grep"],
|
||||
stdin=proc_sub.stdout,
|
||||
stdout=subprocess.PIPE,
|
||||
shell=False)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user