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

Function parent

test/sequential/test-net-GH-5504.js:70–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70function parent() {
71 const spawn = require('child_process').spawn;
72 const node = process.execPath;
73
74 const s = spawn(node, [__filename, 'server'], {
75 env: Object.assign(process.env, {
76 NODE_DEBUG: 'net',
77 }),
78 });
79
80 wrap(s.stderr, process.stderr, 'SERVER 2>');
81 wrap(s.stdout, process.stdout, 'SERVER 1>');
82 s.on('exit', common.mustCall());
83
84 s.stdout.once('data', common.mustCall(function() {
85 const c = spawn(node, [__filename, 'client']);
86 wrap(c.stderr, process.stderr, 'CLIENT 2>');
87 wrap(c.stdout, process.stdout, 'CLIENT 1>');
88 c.on('exit', common.mustCall());
89 }));
90
91 function wrap(inp, out, w) {
92 inp.setEncoding('utf8');
93 inp.on('data', function(chunk) {
94 chunk = chunk.trim();
95 if (!chunk) return;
96 out.write(`${w}${chunk.split('\n').join(`\n${w}`)}\n`);
97 });
98 }
99}

Callers 1

Calls 6

assignMethod · 0.80
wrapFunction · 0.70
requireFunction · 0.50
spawnFunction · 0.50
onMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…