Browse Source

benchmark: terminate child process on Windows

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: https://github.com/nodejs/node/pull/12658
Ref: https://github.com/nodejs/node/issues/12560
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
995423e790
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 10
      benchmark/child_process/child-process-exec-stdout.js

10
benchmark/child_process/child-process-exec-stdout.js

@ -10,7 +10,8 @@ const bench = common.createBenchmark(main, {
dur: [5] dur: [5]
}); });
const exec = require('child_process').exec; const child_process = require('child_process');
const exec = child_process.exec;
function main(conf) { function main(conf) {
bench.start(); bench.start();
@ -28,7 +29,12 @@ function main(conf) {
}); });
setTimeout(function() { setTimeout(function() {
child.kill();
bench.end(bytes); 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); }, dur * 1000);
} }

Loading…
Cancel
Save