Questions: Process Creation: fork() and exec()

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A program calls fork(). After fork() returns, how many processes are executing the instruction immediately after the fork() call?

AOne — the parent continues and the child starts from the beginning of main()
BOne — the child takes over execution and the parent is suspended
CTwo — both parent and child resume at the same point with different return values
DTwo — the parent continues normally; the child automatically starts a new program
Question 2 Multiple Choice

A child process calls execvp() to run a new program. The call succeeds. What happens to the child process's original code, stack, and heap?

AThey are preserved and available when the new program finishes
BThey are saved to disk and restored if exec() is called again
CThey are completely replaced by the new program's image; exec() does not return
DThey are shared with the parent process via copy-on-write until the child exits
Question 3 True / False

After fork() is called, the child process starts execution from the beginning of the main() function.

TTrue
FFalse
Question 4 True / False

The fork-then-exec pattern gives the child process an opportunity to configure its environment — such as redirecting file descriptors — before the new program starts.

TTrue
FFalse
Question 5 Short Answer

Explain why it is said that fork() 'returns twice.' What does each return value mean, and how does a program use them to take different actions in the parent vs. the child?

Think about your answer, then reveal below.