107 cmd =
'ps -e -o pid= -o comm='
111 p = subprocess.Popen(cmd,
112 stdout=subprocess.PIPE,
113 stderr=subprocess.PIPE,
115 universal_newlines=
True)
116 output, stderr = p.communicate()
118 lines = output.splitlines()
123 if len(split) >= 2
and " ".join(split[1:]).endswith(process_name):
124 results.append(split[0])
129 cmd =
'tasklist /FI "IMAGENAME eq %s" /NH' % process_name
132 p = subprocess.Popen(cmd,
133 stdout=subprocess.PIPE,
134 stderr=subprocess.PIPE,
136 universal_newlines=
True)
137 output, stderr = p.communicate()
139 lines = output.splitlines()
143 if len(split) > 2
and split[0] == process_name:
144 results.append(split[1])
156 command_pattern = STACK_INFO_COMMAND.get(os_name,
False)
158 p = subprocess.Popen(command_pattern % pid,
159 stdout=subprocess.PIPE,
160 stderr=subprocess.PIPE,
162 universal_newlines=
True)
163 stdout, stderr = p.communicate()
164 stdout = stdout.splitlines()
165 stderr = stderr.splitlines()
171 print(
" Stack (stderr):")