Question: Consider the following C program (assuming that necessary header files are included and that there are no compilation or execution errors): int main ( int
Consider the following C program (assuming that necessary header files are included and that there are no compilation or execution errors):
int main(int argc, char **argv) { // Main process's PID=42 pid_t pid = fork(); // creates process with PID=11 if (pid == 0) { pid_t pid2 = fork(); // creates process with PID=25 if (pid2 > 0) { sleep(20); exit(0); } else { sleep(10); printf("** ONE ** "); exit(0); } } else { pid_t pid3 = fork(); // creates process with PID=89 if (pid3 == 0) { sleep(20); exit(0); } sleep(10); pid_t pid4 = fork(); // creates process with PID=123 if (pid4 != 0) { sleep(20); printf("** TWO ** "); exit(0); } waitpid(pid3, NULL, 0); exit(0); } sleep(20); exit(0); } 1 : At what time is ** ONE ** printed to the terminal?
2 : At what time is ** TWO ** printed to the terminal?
3 : What is the PID of the process that prints ** TWO **?
4 : What is the PPID of the process with PID 25?
5 : At what time does the process with PID 89 terminate?
6 : How many children does PID 42 create?
7 : What is the PPID of the last process to exit?
8 : Which processes are alive (i.e., not terminated/zombies) at time 15
9: Give the PID of a process that is a zombie at some point during execution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
