title: How does fork() return for child process
body: <p>I know that fork() returns differently for the child and parent processes, but I'm unable to find information on how this happens. How does the child process receive the return value 0 from fork? And what is the difference in regards to the call stack? As I understand it, for the parent it goes something like this:</p>
  
  <p>parent process--invokes fork-->system_call--calls fork-->fork executes--returns to-->system_call--returns to-->parent process.</p>
  
  <p>What happens in the child process?</p>