CS FundamentalsHardGATE CS

After fork(), a parent and child both write to a file descriptor that was opened before the fork, without O_APPEND. Why do their writes not overwrite each other?

  1. A. The kernel gives the child a copy of the file
  2. B. Both descriptors refer to the same open-file description, so they share one file offset that each write advances
  3. C. Each process gets its own offset starting at 0
  4. D. Writes from children are buffered until the parent exits

Correct answer: B. Both descriptors refer to the same open-file description, so they share one file offset that each write advances

fork duplicates descriptors like dup(): they share the open-file description and its offset, so sequential writes advance the same position (interleaving is still possible).

More Operating Systems questions

Exams that ask this topic