OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 # | 6 # |
7 | 7 |
8 # A script to kill hanging processs. The tool will return non-zero if any | 8 # A script to kill hanging processs. The tool will return non-zero if any |
9 # process was actually found. | 9 # process was actually found. |
10 # | 10 # |
11 | 11 |
12 import optparse | 12 import optparse |
13 import os | 13 import os |
14 import signal | 14 import signal |
15 import subprocess | 15 import subprocess |
16 import sys | 16 import sys |
17 | 17 |
18 import utils | 18 import utils |
19 | 19 |
20 | 20 |
21 os_name = utils.GuessOS() | 21 os_name = utils.GuessOS() |
22 | 22 |
23 POSIX_INFO = 'ps -p %s -o args' | 23 POSIX_INFO = 'ps -p %s -o args' |
24 | 24 |
25 EXECUTABLE_NAMES = { | 25 EXECUTABLE_NAMES = { |
26 'win32': { | 26 'win32': { |
27 'chrome': 'chrome.exe', | 27 'chrome': 'chrome.exe', |
28 'content_shell': 'content_shell.exe', | 28 'content_shell': 'content_shell.exe', |
| 29 'dart_bootstrap': 'dart_bootstrap.exe', |
29 'dart': 'dart.exe', | 30 'dart': 'dart.exe', |
| 31 'dart_precompiled_runtime': 'dart_precompiled_runtime.exe', |
| 32 'firefox': 'firefox.exe', |
| 33 'gen_snapshot': 'gen_snapshot.exe', |
| 34 'git': 'git.exe', |
30 'iexplore': 'iexplore.exe', | 35 'iexplore': 'iexplore.exe', |
31 'firefox': 'firefox.exe', | |
32 'git': 'git.exe', | |
33 'svn': 'svn.exe', | 36 'svn': 'svn.exe', |
34 'fletch': 'fletch.exe', | |
35 'fletch-vm': 'fletch-vm.exe', | |
36 }, | 37 }, |
37 'linux': { | 38 'linux': { |
38 'chrome': 'chrome', | 39 'chrome': 'chrome', |
39 'content_shell': 'content_shell', | 40 'content_shell': 'content_shell', |
| 41 'dart_bootstrap': 'dart_bootstrap', |
40 'dart': 'dart', | 42 'dart': 'dart', |
41 'firefox': 'firefox.exe', | 43 'dart_precompiled_runtime': 'dart_precompiled_runtime', |
| 44 'firefox': 'firefox', |
| 45 'gen_snapshot': 'gen_snapshot', |
42 'git': 'git', | 46 'git': 'git', |
43 'svn': 'svn', | 47 'svn': 'svn', |
44 'fletch': 'fletch', | |
45 'fletch-vm': 'fletch-vm', | |
46 }, | 48 }, |
47 'macos': { | 49 'macos': { |
48 'chrome': 'Chrome', | 50 'chrome': 'Chrome', |
49 'chrome_helper': 'Chrome Helper', | 51 'chrome_helper': 'Chrome Helper', |
50 'content_shell': 'Content Shell', | 52 'content_shell': 'Content Shell', |
| 53 'dart_bootstrap': 'dart_bootstrap', |
51 'dart': 'dart', | 54 'dart': 'dart', |
| 55 'dart_precompiled_runtime': 'dart_precompiled_runtime', |
52 'firefox': 'firefox', | 56 'firefox': 'firefox', |
| 57 'gen_snapshot': 'gen_snapshot', |
| 58 'git': 'git', |
53 'safari': 'Safari', | 59 'safari': 'Safari', |
54 'git': 'git', | |
55 'svn': 'svn', | 60 'svn': 'svn', |
56 'fletch': 'fletch', | |
57 'fletch-vm': 'fletch-vm', | |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 INFO_COMMAND = { | 64 INFO_COMMAND = { |
62 'win32': 'wmic process where Processid=%s get CommandLine', | 65 'win32': 'wmic process where Processid=%s get CommandLine', |
63 'macos': POSIX_INFO, | 66 'macos': POSIX_INFO, |
64 'linux': POSIX_INFO, | 67 'linux': POSIX_INFO, |
65 } | 68 } |
66 | 69 |
67 STACK_INFO_COMMAND = { | 70 STACK_INFO_COMMAND = { |
68 'win32': None, | 71 'win32': None, |
69 'macos': '/usr/bin/sample %s 1 4000 -mayDie', | 72 'macos': '/usr/bin/sample %s 1 4000 -mayDie', |
70 'linux': '/usr/bin/eu-stack -p %s', | 73 'linux': '/usr/bin/eu-stack -p %s', |
71 } | 74 } |
72 | 75 |
73 def GetOptions(): | 76 def GetOptions(): |
74 parser = optparse.OptionParser("usage: %prog [options]") | 77 parser = optparse.OptionParser("usage: %prog [options]") |
75 parser.add_option("--kill_dart", default=True, | 78 parser.add_option("--kill_dart", default=True, |
76 help="Kill all dart processes") | 79 help="Kill all dart processes") |
77 parser.add_option("--kill_fletch", default=True, | |
78 help="Kill all fletch and fletch-vm processes") | |
79 parser.add_option("--kill_vc", default=True, | 80 parser.add_option("--kill_vc", default=True, |
80 help="Kill all git and svn processes") | 81 help="Kill all git and svn processes") |
81 parser.add_option("--kill_browsers", default=False, | 82 parser.add_option("--kill_browsers", default=False, |
82 help="Kill all browser processes") | 83 help="Kill all browser processes") |
83 (options, args) = parser.parse_args() | 84 (options, args) = parser.parse_args() |
84 return options | 85 return options |
85 | 86 |
86 | 87 |
87 def GetPidsPosix(process_name): | 88 def GetPidsPosix(process_name): |
88 # This is to have only one posix command, on linux we could just do: | 89 # This is to have only one posix command, on linux we could just do: |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 status += Kill('content_shell') | 218 status += Kill('content_shell') |
218 return status | 219 return status |
219 | 220 |
220 def KillVCSystems(): | 221 def KillVCSystems(): |
221 status = Kill('git') | 222 status = Kill('git') |
222 status += Kill('svn') | 223 status += Kill('svn') |
223 return status | 224 return status |
224 | 225 |
225 def KillDart(): | 226 def KillDart(): |
226 status = Kill("dart", dump_stacks=True) | 227 status = Kill("dart", dump_stacks=True) |
227 return status | 228 status += Kill("dart_bootstrap", dump_stacks=True) |
228 | 229 status += Kill("gen_snapshot", dump_stacks=True) |
229 def KillFletch(): | 230 status += Kill("dart_precompiled_runtime", dump_stacks=True) |
230 status = Kill("fletch") | |
231 status += Kill("fletch-vm") | |
232 return status | 231 return status |
233 | 232 |
234 def Main(): | 233 def Main(): |
235 options = GetOptions() | 234 options = GetOptions() |
236 status = 0 | 235 status = 0 |
237 if options.kill_dart: | 236 if options.kill_dart: |
238 if os_name == "win32": | 237 if os_name == "win32": |
239 # TODO(24086): Add result of KillDart into status once pub hang is fixed. | 238 # TODO(24086): Add result of KillDart into status once pub hang is fixed. |
240 KillDart() | 239 KillDart() |
241 else: | 240 else: |
242 status += KillDart() | 241 status += KillDart() |
243 if options.kill_fletch: | |
244 status += KillFletch() | |
245 if options.kill_vc: | 242 if options.kill_vc: |
246 status += KillVCSystems() | 243 status += KillVCSystems() |
247 if options.kill_browsers: | 244 if options.kill_browsers: |
248 status += KillBrowsers() | 245 status += KillBrowsers() |
249 return status | 246 return status |
250 | 247 |
251 if __name__ == '__main__': | 248 if __name__ == '__main__': |
252 sys.exit(Main()) | 249 sys.exit(Main()) |
OLD | NEW |