Skip to content

Commit b42cd1c

Browse files
committed
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. Refs: nodejs#12560
1 parent b7a341d commit b42cd1c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const bench = common.createBenchmark(main, {
1010
dur: [5]
1111
});
1212

13-
const exec = require('child_process').exec;
13+
const child_process = require('child_process');
14+
const exec = child_process.exec;
1415
function main(conf) {
1516
bench.start();
1617

@@ -29,7 +30,12 @@ function main(conf) {
2930
});
3031

3132
setTimeout(function() {
32-
child.kill();
3333
bench.end(bytes);
34+
if (process.platform === 'win32') {
35+
// Sometimes there's a yes.exe process left hanging around on Windows...
36+
child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
37+
} else {
38+
child.kill();
39+
}
3440
}, dur * 1000);
3541
}

0 commit comments

Comments
 (0)