kill-old-processes 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. import os, sys
  26. def main():
  27. tasksToKillWin = [
  28. "cl.exe",
  29. "devenv.com",
  30. "devenv.exe",
  31. "DumpRenderTree.exe",
  32. "DumpRenderTree_debug.exe",
  33. "httpd.exe",
  34. "imagediff.exe",
  35. "imagediff_debug.exe",
  36. "jsc.exe",
  37. "jsc_debug.exe",
  38. "LightTPD.exe",
  39. "link.exe",
  40. "midl.exe",
  41. "perl.exe",
  42. "Safari.exe",
  43. "svn.exe",
  44. "testapi.exe",
  45. "testapi_debug.exe",
  46. "VcBuildHelper.exe",
  47. "wdiff.exe",
  48. "WebKit2WebProcess.exe",
  49. "WebKit2WebProcess_debug.exe",
  50. "WebKitTestRunner.exe",
  51. "WebKitTestRunner_debug.exe",
  52. ]
  53. tasksToKillMac = [
  54. "apache2",
  55. "cc1plus",
  56. "cc1objplus",
  57. "clang",
  58. r"clang\\+\\+",
  59. "gcc-4.2",
  60. "httpd",
  61. "i686-apple-darwin10-gcc-4.2.1",
  62. "jsc",
  63. "make",
  64. "pboard", # FIXME: https://bugs.webkit.org/show_bug.cgi?id=81012
  65. "per5.12",
  66. "perl",
  67. "Problem Reporter",
  68. "ruby",
  69. "Safari Web Content",
  70. "Safari",
  71. "svn",
  72. "DumpRenderTree",
  73. "TestWebKitAPI Web Content",
  74. "TestWebKitAPI",
  75. "WebKitPluginAgen", # FIXME: Why no 't'?
  76. "WebKitTestRunner Web Content",
  77. "WebKitTestRunner",
  78. "WebProcess",
  79. "xcodebuild",
  80. ]
  81. taskToKillUnix = [
  82. "apache2",
  83. "cc1plus",
  84. "DumpRenderTree",
  85. "gold",
  86. "httpd",
  87. "ld",
  88. "make",
  89. "ruby",
  90. "svn",
  91. "webkit_unit_tests",
  92. "WebKitTestRunner",
  93. "Xvfb",
  94. ]
  95. if sys.platform == 'darwin':
  96. for task in tasksToKillMac:
  97. os.system("killall -9 -v -m " + task)
  98. # Kill all instances of python executing run-webkit-tests
  99. os.system("ps aux | grep -E '.+/Python .+(run_webkit_tests|run-webkit-tests)' | grep -v grep | awk '{print $2}' | xargs kill")
  100. elif sys.platform == 'cygwin' or sys.platform == 'win32':
  101. for task in tasksToKillWin:
  102. os.system("taskkill /t /f /im " + task)
  103. elif sys.platform.startswith('linux'):
  104. for task in taskToKillUnix:
  105. os.system("killall -9 -v " + task)
  106. os.system("ps aux | grep -P '.+/python .+(run_webkit_tests|run-webkit-tests)' | grep -v grep | awk '{print $2}' | xargs kill")
  107. else:
  108. sys.exit()
  109. # FIXME: Should we return an exit code based on how the kills went?
  110. if __name__ == '__main__':
  111. sys.exit(main())