For a typical C program, we do something like this to create a new process:
int main(void)
{
pid_t childPID;
childPID = fork();
if(childPID >0){
do something
}
else if(childPID == 0){
do something
}
else {
do something
}
}
but in a node.js program, the fork is usually done in the if statement:
var cluster = require('cluster');
if (cluster.isMaster) {
do something
cluster.fork()
}
else{
do something for the child process
}
Why we can create child processes in the if statement in Node.js? Why does not the child process skip the else block?
Thanks!