From d9380fbdcad743166717c698162793a3f68c68ff Mon Sep 17 00:00:00 2001 From: yeputons Date: Mon, 20 Jan 2014 17:34:55 +0400 Subject: [PATCH] #224: spec/lib/runner.js: killProcessFamily() now works on Windows (using taskkill.exe) --- spec/lib/runner.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/lib/runner.js b/spec/lib/runner.js index a59afee..24f983c 100644 --- a/spec/lib/runner.js +++ b/spec/lib/runner.js @@ -8,7 +8,7 @@ var utils = require('./utils.js'); var wrench = require('wrench'); var fstream = require('fstream'); -var meteoriteExecutable = path.resolve(path.join('bin', 'mrt.js')); +var meteoriteExecutable = path.resolve(path.join('bin', 'mrt.bat')); var matchesSpecs = function(output, specs) { return _.all(specs, function(spec) { @@ -18,6 +18,13 @@ var matchesSpecs = function(output, specs) { // kill the process family described by process, then send done the error var killProcessFamily = function(child, error, done) { + if (process.platform === 'win32') { + // We do not use /PID , because it will fail if process was already terminated + exec('taskkill /F /T /FI "PID eq ' + child.pid + '"', function(killErr) { + done(error || killErr); + }); + return; + } // we need to grab a table of process ids and parent ids to form a tree out of exec('ps -opid -oppid', function(err, rawData) { // parse the list of process ids and parent ids