summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-01-27 16:48:44 -0500
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-01-27 16:48:44 -0500
commit97c4028c0f42729594dee8a6420ee8153928f0fd (patch)
tree1265204720fb25ab83c6a2f57b8b6d000c905eec
parentbcfb7a02bbb98938cc20210c17f78b1a84ad7fff (diff)
downloadmongo-97c4028c0f42729594dee8a6420ee8153928f0fd.tar.gz
SERVER-21875 Support self-termination of hang analyzer on Windows.
(cherry picked from commit d5510db2d57fea4263a8ca7a8bc3dcff88df310a)
-rwxr-xr-xbuildscripts/hang_analyzer.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/buildscripts/hang_analyzer.py b/buildscripts/hang_analyzer.py
index 1d5f8c4772d..338c6c96446 100755
--- a/buildscripts/hang_analyzer.py
+++ b/buildscripts/hang_analyzer.py
@@ -25,6 +25,9 @@ import time
from distutils import spawn
from optparse import OptionParser
+if sys.platform == "win32":
+ import win32process
+
def call(a = []):
sys.stdout.write(str(a) + "\n")
sys.stdout.flush()
@@ -354,7 +357,13 @@ def signal_process(pid):
def timeout_protector():
print "Script timeout has been hit, terminating"
- os.kill(os.getpid(), signal.SIGKILL)
+ if sys.platform == "win32":
+ # Have the process exit with code 9 when it terminates itself to closely match the exit code
+ # of the process when it sends itself a SIGKILL.
+ handle = win32process.GetCurrentProcess()
+ win32process.TerminateProcess(handle, 9)
+ else:
+ os.kill(os.getpid(), signal.SIGKILL)
# Basic procedure