This is a tricky program that requires you to trace the return values of each fork() call depending on which process it was called in. Therefore, tracing the output of the program will require you to draw an accurate fork diagram. Try to hand trace the output of this code by drawing a fork diagram, keeping track of each process and their function calls. When you're ready to check your answer, press the button below and watch the animation to see how I draw a fork diagram for this program.
fork() == fork() is false
fork() == fork() is false
fork() == fork() is false
fork() == fork() is true
Since these 4 statements are being printed simultaneously, the printing order can change from one run to another.