π΄The fork system call
In this section we shall see how the fork() system call works
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]){
int id = fork();
char *pr = (id == 0) ? "child" : "parent";
printf("Hello World from %s process\n", pr);
return 0;
}
/*Output
Hello World from parent process
Hello World from child process
*/Visualizing the fork tree

Last updated