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?
- A. fd 4 at 0, fd 5 at 10
- B. Both at 10
- C. Both at 0
- 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
- After fork(), a parent and child both write to a file descriptor that was opened before the fork, without OAPPEND. Why do their writes not…
- Which statement about access-control lists (ACLs) versus capability lists is correct?
- A setuid-root program calls access(path, ROK) to check the real user may read path, then calls open(path). Which vulnerability does this…
- Which defence makes a stack-buffer-overflow attack that jumps to injected shellcode on the stack fail, even if the return address is…
- In the Bell–LaPadula confidentiality model, which rules apply?
- Which component of a computer can a hypervisor of TYPE 1 run on directly?