The node.js API documents using an extra stdio (fd=4) when spawning a child process:
// Open an extra fd=4, to interact with programs present a
// startd-style interface.
spawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });
That stdio would be available to the parent process via ChildProcess.stdio[fd]
.
How can the child process access these extra stdios? Let's use a stream instead of a pipe on file descriptor 3 (fd=3).
/* parent process */
// open file for read/write
var mStream = fs.openSync('./shared-stream', 'r+');
// spawn child process with stream object as fd=3
spawn('node', ['/path/to/child.js'], {stdio: [0, 1, 2, mStream] });