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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!