What does the fork() system call return to the child process when it succeeds?
Correct answer A. 0
On success fork() returns twice: the parent receives the new child's PID, while the child receives 0. This difference is how the code tells which copy it is running in. A return of -1 occurs only in the parent when the call fails and no child is created. The child can obtain its parent's PID with getppid() rather than from fork().
Answer checked How we write and check questions
Discussion