Question: h) Beside ANSWER_h, write the letter for the statement below that best explains what happens when we run the following program. (Assume it compiles correctly.)

h) Beside ANSWER_h, write the letter for the statement below that best explains what happens when we run the following program. (Assume it compiles correctly.) A: The program prints "Waited for 1 processes" B: The program prints "Waited for 1 processesWaited for 1 processes" C: The program prints "Waited for 2 processes" D: The program prints "Waited for processesWaited for 1 processes" E: The program terminates normally, but prints something other than one of the statements in A, B, C, or D F: The program terminates with an error G: The program does not terminate without explicitly killing it ANSWER_h: int main() { int r1 = fork(); if (r1 == 0) { r1 = fork(); if (r1 == 0) { exit(0); } } int sum = 0; while (wait (NULL) != -1) { sum++; } fprintf(stderr, "Waited for %d processes", sum); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
