Skip to content

Commit

Permalink
benchmark: terminate child process on Windows
Browse files Browse the repository at this point in the history
test-benchmark-child-process failures reveal that
child-process-exec-stdout benchmark sometimes leaves around a stray
yes.exe process. Add code to terminate the process.

PR-URL: nodejs/node#12658
Ref: nodejs/node#12560
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and andrew749 committed Jul 19, 2017
1 parent e270017 commit 5efb302
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions benchmark/child_process/child-process-exec-stdout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const bench = common.createBenchmark(main, {
dur: [5]
});

const exec = require('child_process').exec;
const child_process = require('child_process');
const exec = child_process.exec;
function main(conf) {
bench.start();

Expand All @@ -28,7 +29,12 @@ function main(conf) {
});

setTimeout(function() {
child.kill();
bench.end(bytes);
if (process.platform === 'win32') {
// Sometimes there's a yes.exe process left hanging around on Windows...
child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
} else {
child.kill();
}
}, dur * 1000);
}

0 comments on commit 5efb302

Please sign in to comment.