CS FundamentalsVery hardGATE CS

A process opens the same file twice with two separate open() calls, getting fd 3 and fd 4, and also calls dup(3) to get fd 5. It then reads 10 bytes via fd 3. Where are the offsets of fd 4 and fd 5?

  1. A. fd 4 at 0, fd 5 at 10
  2. B. Both at 10
  3. C. Both at 0
  4. D. fd 4 at 10, fd 5 at 0

Correct answer: A. fd 4 at 0, fd 5 at 10

Each open() creates a new open-file description with its own offset. dup() makes another descriptor that shares the SAME description (and offset) as fd 3, so fd 5 is at 10.

More Operating Systems questions

Exams that ask this topic