Question: Examine below program fragment and answer the following questions. for (i=0; i <4; i++) if (pid else = pid = fork(); == 0) sleep(10);
Examine below program fragment and answer the following questions. for (i=0; i 0) printf("This child has terminated: %d ", pid); Assume all fork() calls are successfully executed. a. (4 points) How many processes will be created by executing this program? b. (6 points) How many SIGCHLD signals will be generated by executing this program? c. (8 points) How many times will the printf() statement be printed out? d. (2 points) Now imagine you write your own UNIX shell by making a small change: instead of calling fork() then exec() to launch a new job, your code instead first calls exec() and then calls fork(). How does this change impact the shell, if any? (Explain) Justify your answers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
