MCPcopy Index your code
hub / github.com/nodejs/node / childProcessExecStdout

Function childProcessExecStdout

benchmark/child_process/child-process-exec-stdout.js:15–40  ·  view source on GitHub ↗
({ dur, len })

Source from the content-addressed store, hash-verified

13});
14
15function childProcessExecStdout({ dur, len }) {
16 bench.start();
17
18 const maxDuration = dur * 1000;
19 const cmd = `yes "${'.'.repeat(len)}"`;
20 const child = exec(cmd, { 'stdio': ['ignore', 'pipe', 'ignore'] });
21
22 let bytes = 0;
23 child.stdout.on('data', (msg) => {
24 bytes += msg.length;
25 });
26
27 setTimeout(() => {
28 bench.end(bytes);
29 if (isWindows) {
30 // Sometimes there's a yes.exe process left hanging around on Windows.
31 try {
32 execSync(`taskkill /f /t /pid ${child.pid}`);
33 } catch {
34 // This is a best effort kill. stderr is piped to parent for tracing.
35 }
36 } else {
37 child.kill();
38 }
39 }, maxDuration);
40}

Callers

nothing calls this directly

Calls 7

execSyncFunction · 0.85
killMethod · 0.80
execFunction · 0.50
setTimeoutFunction · 0.50
startMethod · 0.45
onMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…