HW2 released: 02/03, 12:00 due: 02/09, 23:59 Answer the following questions. Submit your answers to Canvas assignments. There is an entry for this homework. 1. Read handout week.3a (https://naizhengtan.github.io/22spring/notes/handout_w03a.pdf) and answer the questions below. 1.a What does "0" in "wait(0)" (line 23) mean? (1 point) 1.b Read "6. Commentary" and copy-paste it below. (1 point) 1.c Why do lines 143 and 144 close the "fdarray"? In other words, what can go wrong without closing them? (2 points) 2. Play with fork [hints: -- below are valid code. -- we omit header files. -- to see which header files to include, use "$ man ". (e.g., "$ man fork" to see which header files define "fork".) ] 2.a Run the following code for three times. (2 points) int main() { // [update 2/4: the "printf"s below were "print", which are typos.] printf("hello world"); fork(); printf("\n"); } Write down the outputs below and answer the question. Answer: first time output: """ // write your output here """ second time output: """ // write your output here """ third time output: """ // write your output here """ If "hello world" appear twice in any outputs, explain why in 1-2 sentences. (write "CONDITION FALSE" if the "hello world" only appear once.) 2.b Run the following code for three times. (2 points) int main() { fork(); fork(); // [update 2/4: fix the double quotation marks] printf("\nhello world"); } Write down the outputs below and answer the question. Answer: first time output: """ // write your output here """ second time output: """ // write your output here """ third time output: """ // write your output here """ If the outputs are different, why? Explain in 1-2 sentences. (write "CONDITION FALSE" if the outputs are the same) 2.c Run the following code for three times. (2 points) int main() { int pid = fork(); if (pid > 0) { wait(NULL); } int pid2 = fork(); if (pid2 > 0) { wait(NULL); } printf("\nhello world"); } Write down the outputs below and answer the question. Answer: first time output: """ // write your output here """ second time output: """ // write your output here """ third time output: """ // write your output here """ If the outputs are the same, explain why in 1-2 sentences. (write "CONDITION FALSE" if the outputs are different)