1'use strict'; 2// Refs: https://github.com/nodejs/node/issues/947 3const common = require('../common'); 4const assert = require('assert'); 5const cp = require('child_process'); 6 7if (process.argv[2] === 'child') { 8 process.on('message', common.mustCall((msg) => { 9 assert.strictEqual(msg, 'go'); 10 // The following console.log is an integral part 11 // of the test. If this regress, this call will 12 // cause the process to exit with 1 13 console.log('logging should not cause a crash'); 14 process.disconnect(); 15 })); 16} else { 17 const child = cp.fork(__filename, ['child'], { silent: true }); 18 19 child.on('close', common.mustCall((exitCode, signal) => { 20 assert.strictEqual(exitCode, 0); 21 assert.strictEqual(signal, null); 22 })); 23 24 child.stdout.destroy(); 25 child.send('go'); 26} 27