Question: Suppose we write the following code (pseudo-code) on our shell terminal: int main(int argc, char *argv[]) { int p = fork(); for (int i =
Suppose we write the following code (pseudo-code) on our shell terminal:
int main(int argc, char *argv[]) {
int p = fork();
for (int i = 0; i<=p; i++) {
waitpid(p);
printf ("P_id_1: %d, P_id_2: %d, i = %d ", getpid(), p, i);
p = fork();
}
}
Lets execute the code above. What do you observe and why? What is the printout? How many processes are being created?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
