What is a File Descriptor, and how does the OS use the Open-File Table to manage file access across processes?
Last updated
A file descriptor is a small integer indexing a per-process table (
0,1,2are stdin, stdout, stderr), whose entries point into a system-wide open-file table.Each open-file table entry holds the current offset, access mode, and a pointer to the in-memory inode. Separate
open()calls get separate entries with independent offsets.After
fork()ordup(), descriptors share one entry and thus one offset. Reference counts tell the OS whenclose()can release resources.