Fork and Process in C
C Program
Look at the flow of the following C program, greetings.c :
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
if (fork() == 0) {
if (fork() == 0) {
printf(“Hin”);
} else {
if (fork() == 0){
printf(“Hellon”);
} else {
printf(“Howdyn”);
}
}
exit(0);
} else {
printf(“Welcomen”);
}
if (fork() == 0) {
printf(“Byen”);
} else {
printf(“Farewelln”);
}
return 0;
}
Attention: For the sake of simplicity, we make the followingassumptions about process flow control:
All processes are executed on the
PayPal Gateway not configured
PayPal Gateway not configured