REGRESSION (r194660): Legacy WebProcess crashes in ChildProcess::initializeSandbox()
[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         "perl5.12",
71         "perl5.16",
72         "perl",
73         "Problem Reporter",
74         "ruby",
75         "Safari Web Content",
76         "Safari",
77         "svn",
78         "DumpRenderTree",
79         "TestWebKitAPI Web Content",
80         "TestWebKitAPI",
81         "PluginProcess",
82         "com.apple.WebKit.Plugin.64",
83         "com.apple.WebKit.Plugin.32",
84         "com.apple.WebKit.PluginProcess",
85         "com.apple.WebKit.PluginProcess.Development"
86         "WebKitTestRunner Web Content",
87         "WebKitTestRunner",
88         "WebProcess",
89         "xcodebuild",
90         # FIXME: Consider moving iOS-specific tasks to their own list.
91         "Simulator",
92         "LayoutTestRelay"
93     ]
94
95     taskToKillUnix = [
96         "apache2",
97         "cc1plus",
98         "DumpRenderTree",
99         "gold",
100         "httpd",
101         "ld",
102         "make",
103         "ruby",
104         "svn",
105         "webkit_unit_tests",
106         "WebKitTestRunner",
107         "Xvfb",
108     ]
109
110     # This allows to specify on the environment of the bot a list of process that should be killed.
111     tasksToKill = os.getenv("WEBKITBOT_TASKSTOKILL", "").split()
112     if sys.platform == 'darwin':
113         for task in tasksToKill + tasksToKillMac:
114             os.system("killall -9 -v -m " + task)
115         # Kill all instances of python executing run-webkit-tests
116         os.system("ps aux | grep -E '.+/Python .+(run_webkit_tests|run-webkit-tests|mod_pywebsocket)' | grep -v grep | awk '{print $2}' | xargs kill")
117     elif sys.platform == 'cygwin' or sys.platform == 'win32':
118         for task in tasksToKill + tasksToKillWin:
119             os.system("taskkill /t /f /im " + task)
120     elif sys.platform.startswith('linux'):
121         for task in tasksToKill + taskToKillUnix:
122             os.system("killall -9 -v " + task)
123         os.system("ps aux | grep -P '.+/python .+(run_webkit_tests|run-webkit-tests|mod_pywebsocket)' | grep -v grep | awk '{print $2}' | xargs kill")
124     else:
125         sys.exit()
126         # FIXME: Should we return an exit code based on how the kills went?
127
128
129 if __name__ == '__main__':
130     sys.exit(main())