Node.js Child Processes

This code was an excerpt from Samer Buna's article hosted on Medium.

The post talks about the different techniches to create child processes in Node.js and their cons ans pros.

We can easily spin a child process using Node’s child_process module and those child processes can easily communicate with each other with a messaging system.

There are four different ways to create a child process in Node: spawn(), fork(), exec(), and execFile().

Events that we can register handlers for with the child_process instances are: * disconnect; * exit; * error; * close; * and message.

The *Sync function

The functions spawn, exec, and execFile from the child_process module also have synchronous blocking versions that will wait until the child process exits. The synchronous version of them are: spawnSync, execSync, and execFileSync.