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 # |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 help="Kill all dart processes") | 43 help="Kill all dart processes") |
44 parser.add_option("--kill_browsers", default=False, | 44 parser.add_option("--kill_browsers", default=False, |
45 help="Kill all browser processes") | 45 help="Kill all browser processes") |
46 (options, args) = parser.parse_args() | 46 (options, args) = parser.parse_args() |
47 return options | 47 return options |
48 | 48 |
49 | 49 |
50 def GetPidsPosix(process_name): | 50 def GetPidsPosix(process_name): |
51 # This is to have only one posix command, on linux we could just do: | 51 # This is to have only one posix command, on linux we could just do: |
52 # pidof process_name | 52 # pidof process_name |
53 cmd = 'ps -e -o pid=,comm=' | 53 cmd = 'ps -e -o pid= -o comm=' |
54 # Sample output: | 54 # Sample output: |
55 # 1 /sbin/launchd | 55 # 1 /sbin/launchd |
56 # 80943 /Applications/Safari.app/Contents/MacOS/Safari | 56 # 80943 /Applications/Safari.app/Contents/MacOS/Safari |
57 p = subprocess.Popen(cmd, | 57 p = subprocess.Popen(cmd, |
58 stdout=subprocess.PIPE, | 58 stdout=subprocess.PIPE, |
59 stderr=subprocess.PIPE, | 59 stderr=subprocess.PIPE, |
60 shell=True) | 60 shell=True) |
61 output, stderr = p.communicate() | 61 output, stderr = p.communicate() |
62 results = [] | 62 results = [] |
63 lines = output.splitlines() | 63 lines = output.splitlines() |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 options = GetOptions() | 163 options = GetOptions() |
164 status = 0 | 164 status = 0 |
165 if (options.kill_dart): | 165 if (options.kill_dart): |
166 status += KillDart(); | 166 status += KillDart(); |
167 if (options.kill_browsers): | 167 if (options.kill_browsers): |
168 status += KillBrowsers() | 168 status += KillBrowsers() |
169 return status | 169 return status |
170 | 170 |
171 if __name__ == '__main__': | 171 if __name__ == '__main__': |
172 sys.exit(Main()) | 172 sys.exit(Main()) |
OLD | NEW |