Differential D61687 Diff 200160 packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
Changeset View
Changeset View
Standalone View
Standalone View
packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
Show First 20 Lines • Show All 920 Lines • ▼ Show 20 Lines | def process_is_running(pid, unknown_value=True): | ||||
elif platform.system() in ['Darwin', 'Linux', 'FreeBSD', 'NetBSD']: | elif platform.system() in ['Darwin', 'Linux', 'FreeBSD', 'NetBSD']: | ||||
# Build the list of running process ids | # Build the list of running process ids | ||||
output = subprocess.check_output( | output = subprocess.check_output( | ||||
"ps ax | awk '{ print $1; }'", shell=True).decode("utf-8") | "ps ax | awk '{ print $1; }'", shell=True).decode("utf-8") | ||||
text_process_ids = output.split('\n')[1:] | text_process_ids = output.split('\n')[1:] | ||||
# Convert text pids to ints | # Convert text pids to ints | ||||
process_ids = [int(text_pid) | process_ids = [int(text_pid) | ||||
for text_pid in text_process_ids if text_pid != ''] | for text_pid in text_process_ids if text_pid != ''] | ||||
elif platform.system() == 'Windows': | |||||
output = subprocess.check_output( | |||||
"for /f \"tokens=2 delims=,\" %F in ('tasklist /nh /fi \"PID ne 0\" /fo csv') do @echo %~F", shell=True).decode("utf-8") | |||||
text_process_ids = output.split('\n')[1:] | |||||
process_ids = [int(text_pid) | |||||
for text_pid in text_process_ids if text_pid != ''] | |||||
# elif {your_platform_here}: | # elif {your_platform_here}: | ||||
# fill in process_ids as a list of int type process IDs running on | # fill in process_ids as a list of int type process IDs running on | ||||
# the local system. | # the local system. | ||||
else: | else: | ||||
# Don't know how to get list of running process IDs on this | # Don't know how to get list of running process IDs on this | ||||
# OS, so return the "don't know" value. | # OS, so return the "don't know" value. | ||||
return unknown_value | return unknown_value | ||||
Show All 9 Lines |