[Mac] kill-old-processes should kill more processes
[WebKit-https.git] / Tools / BuildSlaveSupport / kill-old-processes
1 #!/usr/bin/python
2 # Copyright (C) 2010 Apple Inc.  All rights reserved.
3 # Copyright (C) 2011 Google Inc.  All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 # 1.  Redistributions of source code must retain the above copyright
10 #     notice, this list of conditions and the following disclaimer.
11 # 2.  Redistributions in binary form must reproduce the above copyright
12 #     notice, this list of conditions and the following disclaimer in the
13 #     documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 import os, sys
27
28
29 def main():
30     tasksToKillWin = [
31         "cl.exe",
32         "devenv.com",
33         "devenv.exe",
34         "DumpRenderTree.exe",
35         "DumpRenderTree_debug.exe",
36         "httpd.exe",
37         "imagediff.exe",
38         "imagediff_debug.exe",
39         "jsc.exe",
40         "jsc_debug.exe",
41         "LightTPD.exe",
42         "link.exe",
43         "midl.exe",
44         "perl.exe",
45         "Safari.exe",
46         "svn.exe",
47         "testapi.exe",
48         "testapi_debug.exe",
49         "VcBuildHelper.exe",
50         "wdiff.exe",
51         "WebKit2WebProcess.exe",
52         "WebKit2WebProcess_debug.exe",
53         "WebKitTestRunner.exe",
54         "WebKitTestRunner_debug.exe",
55     ]
56
57     tasksToKillMac = [
58         "apache2",
59         "cc1plus",
60         "cc1objplus",
61         "clang",
62         r"clang\\+\\+",
63         "gcc-4.2",
64         "httpd",
65         "i686-apple-darwin10-gcc-4.2.1",
66         "ImageDiff",
67         "jsc",
68         "LayoutTestHelper",
69         "make",
70         "pboard", # FIXME: https://bugs.webkit.org/show_bug.cgi?id=81012
71         "perl5.12",
72         "perl5.16",
73         "perl",
74         "Problem Reporter",
75         "ruby",
76         "Safari Web Content",
77         "Safari",
78         "svn",
79         "DumpRenderTree",
80         "TestWebKitAPI Web Content",
81         "TestWebKitAPI",
82         "PluginProcess",
83         "com.apple.WebKit.Plugin.64",
84         "com.apple.WebKit.Plugin.32",
85         "com.apple.WebKit.PluginProcess",
86         "com.apple.WebKit.PluginProcess.Development"
87         "WebKitTestRunner Web Content",
88         "WebKitTestRunner",
89         "WebProcess",
90         "xcodebuild",
91         "Simulator"  # FIXME: Consider moving iOS-specific tasks to their own list.
92     ]
93
94     taskToKillUnix = [
95         "apache2",
96         "cc1plus",
97         "DumpRenderTree",
98         "gold",
99         "httpd",
100         "ld",
101         "make",
102         "ruby",
103         "svn",
104         "webkit_unit_tests",
105         "WebKitTestRunner",
106         "Xvfb",
107     ]
108
109     if sys.platform == 'darwin':
110         for task in tasksToKillMac:
111             os.system("killall -9 -v -m " + task)
112         # Kill all instances of python executing run-webkit-tests
113         os.system("ps aux | grep -E '.+/Python .+(run_webkit_tests|run-webkit-tests|mod_pywebsocket)' | grep -v grep | awk '{print $2}' | xargs kill")
114     elif sys.platform == 'cygwin' or sys.platform == 'win32':
115         for task in tasksToKillWin:
116             os.system("taskkill /t /f /im " + task)
117     elif sys.platform.startswith('linux'):
118         for task in taskToKillUnix:
119             os.system("killall -9 -v " + task)
120         os.system("ps aux | grep -P '.+/python .+(run_webkit_tests|run-webkit-tests|mod_pywebsocket)' | grep -v grep | awk '{print $2}' | xargs kill")
121     else:
122         sys.exit()
123         # FIXME: Should we return an exit code based on how the kills went?
124
125
126 if __name__ == '__main__':
127     sys.exit(main())