From f24e22446bd60b41d5125d384c5a637ddb46538f Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 3 Jan 2017 15:58:35 -0300 Subject: [PATCH] validate: Properly kill subprocesses on windows --- validate/launcher/baseclasses.py | 5 ++++- validate/launcher/utils.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index bfb7dd4dff..c223c1cea0 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -339,7 +339,10 @@ class Test(Loggable): while res is None: try: self.debug("Subprocess is still alive, sending KILL signal") - self.process.send_signal(signal.SIGKILL) + if utils.is_windows(): + subprocess.call(['taskkill', '/F', '/T', '/PID', str(self.process.pid)]) + else: + self.process.send_signal(signal.SIGKILL) time.sleep(1) except OSError: pass diff --git a/validate/launcher/utils.py b/validate/launcher/utils.py index 20b3fd2dc0..b09b9001fb 100644 --- a/validate/launcher/utils.py +++ b/validate/launcher/utils.py @@ -24,6 +24,7 @@ except ImportError: from . import config import os +import platform import re import shutil import subprocess @@ -159,6 +160,11 @@ def path2url(path): return urllib.parse.urljoin('file:', urllib.request.pathname2url(path)) +def is_windows(): + platname = platform.system().lower() + return platname == 'windows' or 'mingw' in platname + + def url2path(url): path = urllib.parse.urlparse(url).path if "win32" in sys.platform: