From ff32eb57223d199771ff07732f3e802cebbd8d1e Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Fri, 6 Feb 2015 13:53:34 -0800 Subject: [PATCH] In selftest in Windows, kill child processes more In a previous commit we did that in one but not all cases in selftest where we try to kill child processes. --- tools/selftest.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/selftest.js b/tools/selftest.js index 2cc27cc46b..05cc72e7f4 100644 --- a/tools/selftest.js +++ b/tools/selftest.js @@ -1308,14 +1308,7 @@ _.extend(Run.prototype, { if (self.exitStatus === undefined) { self._ensureStarted(); self.client && self.client.stop(); - - if (process.platform === "win32") { - // looks like in Windows `self.proc.kill()` doesn't kill child - // processes. - utils.execFileSync("taskkill", ["/pid", self.proc.pid, '/f', '/t']); - } else { - self.proc.kill(); - } + self._killProcess(); self.expectExit(); } }), @@ -1325,7 +1318,21 @@ _.extend(Run.prototype, { var self = this; if (self.exitStatus === undefined && self.proc) { self.client && self.client.stop(); - self.proc.kill(); + self._killProcess(); + } + }, + + // Kills the running process and it's child processes + _killProcess: function () { + if (!this.proc) + throw new Error("Unexpected: `this.proc` undefined when calling _killProcess"); + + if (process.platform === "win32") { + // looks like in Windows `self.proc.kill()` doesn't kill child + // processes. + utils.execFileSync("taskkill", ["/pid", this.proc.pid, '/f', '/t']); + } else { + this.proc.kill(); } },