Skip to content

Commit

Permalink
In selftest in Windows, kill child processes more
Browse files Browse the repository at this point in the history
In a previous commit we did that in one but not all cases in selftest
where we try to kill child processes.
  • Loading branch information
avital committed Feb 6, 2015
1 parent b276aa7 commit ff32eb5
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tools/selftest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}),
Expand All @@ -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();
}
},

Expand Down

0 comments on commit ff32eb5

Please sign in to comment.