22POSIX_INFO =
'ps -p %s -o args'
26 'chrome':
'chrome.exe',
28 'dartaotruntime':
'dartaotruntime.exe',
29 'dart_precompiled_runtime':
'dart_precompiled_runtime.exe',
30 'firefox':
'firefox.exe',
31 'gen_snapshot':
'gen_snapshot.exe',
33 'iexplore':
'iexplore.exe',
35 'mspdbsrv':
'mspdbsrv.exe',
40 'dartaotruntime':
'dartaotruntime',
41 'dart_precompiled_runtime':
'dart_precompiled_runtime',
43 'gen_snapshot':
'gen_snapshot',
44 'flutter_tester':
'flutter_tester',
49 'chrome_helper':
'Chrome Helper',
51 'dartaotruntime':
'dartaotruntime',
52 'dart_precompiled_runtime':
'dart_precompiled_runtime',
54 'gen_snapshot':
'gen_snapshot',
61 'win32':
'wmic process where Processid=%s get CommandLine',
68 'macos':
'/usr/bin/sample %s 1 4000 -mayDie',
69 'linux':
'/usr/bin/eu-stack -p %s',
74 parser = optparse.OptionParser(
'usage: %prog [options]')
75 true_or_false = [
'True',
'False']
80 choices=true_or_false,
81 help=
"Kill all dart processes")
86 choices=true_or_false,
87 help=
"Kill all git processes")
92 choices=true_or_false,
93 help=
"Kill all visual studio build related processes")
98 choices=true_or_false,
99 help=
"Kill all browser processes")
100 (options, args) = parser.parse_args()
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])
149 if os_name ==
"win32":
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):")
180 p = subprocess.Popen(INFO_COMMAND[os_name] % pid,
181 stdout=subprocess.PIPE,
182 stderr=subprocess.PIPE,
184 universal_newlines=
True)
185 output, stderr = p.communicate()
186 lines = output.splitlines()
191 print(
"Hanging process info:")
192 print(
" PID: %s" % pid)
195 if line:
print(
" Command line: %s" % line)
203 os.kill(
int(pid), signal.SIGKILL)
211 cmd =
"taskkill /F /PID %s" % pid
212 p = subprocess.Popen(cmd,
213 stdout=subprocess.PIPE,
214 stderr=subprocess.PIPE,
216 universal_newlines=
True)
220def Kill(name, dump_stacks=False):
221 if name
not in EXECUTABLE_NAMES[os_name]:
223 print(
"***************** Killing %s *****************" % name)
224 platform_name = EXECUTABLE_NAMES[os_name][name]
228 if os_name ==
"win32":
232 print(
"Killed pid: %s" % pid)
234 print(
" No %s processes found." % name)
239 status =
Kill(
'firefox')
243 status +=
Kill(
'chrome_helper')
244 status +=
Kill(
'iexplore')
245 status +=
Kill(
'safari')
255 status =
Kill(
'vctip')
256 status +=
Kill(
'mspdbsrv')
261 status =
Kill(
"dart", dump_stacks=
True)
262 status +=
Kill(
"gen_snapshot", dump_stacks=
True)
263 status +=
Kill(
"dartaotruntime", dump_stacks=
True)
264 status +=
Kill(
"dart_precompiled_runtime", dump_stacks=
True)
265 status +=
Kill(
"flutter_tester", dump_stacks=
True)
272 if options.kill_dart ==
'True':
273 if os_name ==
"win32":
278 if options.kill_vc ==
'True':
280 if options.kill_vsbuild ==
'True' and os_name ==
'win32':
282 if options.kill_browsers ==
'True':
287if __name__ ==
'__main__':
def print(*args, **kwargs)
def GetPids(process_name)
def PrintPidInfo(pid, dump_stacks)
def GetPidsPosix(process_name)
def Kill(name, dump_stacks=False)
def GetPidsWindows(process_name)
def PrintPidStackInfo(pid)
static SkString join(const CommandLineFlags::StringArray &)