Why dose the program print "Hello World" 2 times rather than only 1 time? The console.log is excuted before cluster.fork().
import * as cluster from "cluster";
console.log("Hello World");
if (cluster.isMaster) {
const worker = cluster.fork();
worker.disconnect();
}
The following c program prints "Hello World" only 1 time
#include <unistd.h>
#include <stdio.h>
int main(void)
{
printf("HelloWorld/n");
fork();
return 0;
}