function test (file) { file = join('fixtures', 'broken-pipe', file) t.test(file, { parallel: true }, async ({ is }) => { const child = fork(join(__dirname, file), { silent: true }) child.stdout.destroy() child.stderr.pipe(process.stdout) const res = await once(child, 'close') is(res, 0) // process exits successfully }) }
test('do not use SonicBoom is someone tampered with process.stdout.write', async ({ isNot }) => { var actual = '' const child = fork(join(__dirname, 'fixtures', 'stdout-hack-protection.js'), { silent: true }) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/^hack/), null) })
function bundleNode(componentPath, fullBundlePath, basePath, bundlePath) { return new Promise((resolve, reject) => { const parameters = [componentPath, fullBundlePath, basePath, bundlePath]; const options = { stdio: [0, 1, 2, "ipc"] }; childProcess = fork(require.resolve("./bundleNode"), parameters, options); // process doesn't exit in watch mode. childProcess.on("message", data => { resolve(); }); }); }
function runYarn(cwd, args, resolveOutput) { const isWin = os.platform() === "win32"; return new Promise((resolve, reject) => { debug("yarn", yarnPath, args, cwd); var child = fork(yarnPath, args || [], { cwd: cwd, stdio: !resolveOutput ? "inherit" : "pipe" }); if (isWin) { // a windows bug. need to press enter sometimes try { // process.stdin.write("\n"); // process.stdin.end(); } catch (e) {} } var output = ""; if (resolveOutput) { child.stdout.on("data", data => { output += data; }); } child.on("exit", code => { debug("yarn completed"); resolve(output); }); }); }
child_process.fork(path.join(__dirname, '../local_http.js'), [`PORT=${port}`, `ROUTE=${route}`, `NAME=${serviceName}`]); } else { parser.check(err => parser.createServer(pkg, port, !!err));
function getBuildInfo(pageData, onClose) { return new Promise(async (resolve, reject) => { const pageId = pageData.id; if (!bundlerProgram) return resolve({ info: false }); const parameters = [ pageData.path, pageData.entryFile, pageData.type, ".zero/zero-builds/" + pageId ]; const options = { stdio: [0, 1, 2, "ipc"] }; const child = fork(bundlerProgram, parameters, options); child.on("message", message => { return resolve({ child, info: message }); }); child.on("close", () => { debug("bundler process closed", pageId); if (onClose) onClose(); }); }); }
var actual2 = '' const child = fork(join(__dirname, '/fixtures/syncfalse.js'), { silent: true }) child.stdout.pipe(writer((s, enc, cb) => { actual2 += s
var actual2 = '' const child = fork(join(__dirname, '/fixtures/syncfalse-child.js'), { silent: true }) child.stdout.pipe(writer((s, enc, cb) => { actual2 += s
function runChild(){ child = childProcess.fork(file, argv); console.log('running node ' + filename, argv); child.on('close', function(){ console.log('stop', filename); }); }
function startWorker() { let args = ['-P', port, '-n', nworker, '-m', memory]; args = args.concat(opt.options.slow ? ['-s'] : ['-M', hostname]); const worker = child_process.fork( __dirname + '/worker.js', args, { execArgv: [ '--expose-gc' ], stdio: 'inherit' }); worker.on('close', startWorker); }
function bundleNode(componentPath, fullBundlePath, basePath, bundlePath) { return new Promise((resolve, reject) => { const parameters = [componentPath, fullBundlePath, basePath, bundlePath]; const options = { stdio: [0, 1, 2, "ipc"] }; childProcess = fork(require.resolve("./bundleNode"), parameters, options); // process doesn't exit in watch mode. childProcess.on("message", data => { resolve(); }); }); }
function bundleNode(componentPath, fullBundlePath, basePath, bundlePath) { return new Promise((resolve, reject) => { const parameters = [componentPath, fullBundlePath, basePath, bundlePath]; const options = { stdio: [0, 1, 2, "ipc"] }; childProcess = fork(require.resolve("./bundleNode"), parameters, options); // process doesn't exit in watch mode. childProcess.on("message", data => { resolve(); }); }); }
function bundleNode(componentPath, fullBundlePath, basePath, bundlePath) { return new Promise((resolve, reject) => { const parameters = [componentPath, fullBundlePath, basePath, bundlePath]; const options = { stdio: [0, 1, 2, "ipc"] }; childProcess = fork(require.resolve("./bundleNode"), parameters, options); // process doesn't exit in watch mode. childProcess.on("message", data => { resolve(); }); }); }
function getBuildInfo(pageData, onClose) { return new Promise(async (resolve, reject) => { const pageId = pageData.id; if (!bundlerProgram) return resolve({ info: false }); const parameters = [ pageData.path, pageData.entryFile, pageData.type, ".zero/zero-builds/" + pageId ]; const options = { stdio: [0, 1, 2, "ipc"] }; const child = fork(bundlerProgram, parameters, options); child.on("message", message => { return resolve({ child, info: message }); }); child.on("close", () => { debug("bundler process closed", pageId); if (onClose) onClose(); }); }); }
function runYarn(cwd, args, resolveOutput) { const isWin = os.platform() === "win32"; return new Promise((resolve, reject) => { debug("yarn", yarnPath, args, cwd); var child = fork(yarnPath, args || [], { cwd: cwd, stdio: !resolveOutput ? "inherit" : "pipe" }); if (isWin) { // a windows bug. need to press enter sometimes try { // process.stdin.write("\n"); // process.stdin.end(); } catch (e) {} } var output = ""; if (resolveOutput) { child.stdout.on("data", data => { output += data; }); } child.on("exit", code => { debug("yarn completed"); resolve(output); }); }); }