Try to kill java if we are killed by a timeout
Change-Id: I10cb818873310a76582cd382b5c6ca105d22bf7c
diff --git a/tools/run_on_as_app.py b/tools/run_on_as_app.py
index 9182539..6d7905e 100755
--- a/tools/run_on_as_app.py
+++ b/tools/run_on_as_app.py
@@ -12,6 +12,7 @@
import os
import optparse
import shutil
+import signal
import subprocess
import sys
import time
@@ -415,6 +416,9 @@
})
]
+def signal_handler(signum, frame):
+ subprocess.call(['pkill', 'java'])
+ raise Exception('Got killed by %s' % signum)
class EnsureNoGradleAlive(object):
def __init__(self, active):
@@ -422,6 +426,8 @@
def __enter__(self):
if self.active:
+ # If we timeout and get a sigterm we should still kill all java
+ signal.signal(signal.SIGTERM, signal_handler)
print 'Running with wrapper that will kill java after'
def __exit__(self, *_):