node.js – Node Child Process understanding additional STDIO pipes beyond 0, 1 and 2 in SPAWN method
I am currently upping my understanding on child processes (only spawn-method) in NodeJS by pondering over the respective manual and many other sources.
All sources (which I have seen so far) only discuss the default three pipes to the parent process; stdin, stdout, and stderr.
These correspond to, or can be configured or addressed in Options thus:
Example [‘ignore’, ‘inherit’, ‘pipe’] or [0, 1, 2] etc.
I have however come across code a couple of times, where additional pipes are being used. Let’s say in the SPAWN method:
Spawned.stdio[3].on('data', (data) => {
PRESTREAM.write(data, 'binary');
});
with Options like:
const Options = {
detached: true,
stdio: ['ignore', 'ignore', 'ignore', 'pipe']
};
Stdio[3] and the 4rth stdio option is what is confusing me here.
Question: I am not trying achieve any specific coding goal or result. I am looking for an explanation or a pointer to helpful documentation to get my head around this part, prior to using child processes in an eminent development project with CPU intensive tasks.
When is it a good idea to configure additional pipes beyond the standard ones? How is this to be implemented?
Any hints would be much appreciated tyvm!
Read more here: Source link
