Most programs you use or write rely on File Descriptors (FDs) β even if you never think about them.
If a process reads input, writes output, opens a file, or sends data over a socket, itβs using FDs behind the scenes.
π What Exactly Is an FD?
A File Descriptor is simply a small integer the kernel gives to a process.
Itβs not the file itself β itβs a handle the kernel uses to manage any I/O resource.
π‘ Why Theyβre So Important
Unified interface: files, pipes, sockets β all use open(), read(), write(), close().
Process isolation: each process has its own FD table.
State tracking: the kernel keeps the read/write offset and mode for each FD, even if multiple processes open the same file.
βοΈ Under the Hood
Linux manages I/O through three layers:
Per-Process FD Table β what your program sees (0, 1, 2, ...).
Open File Table β stores the state of each open resource.
Inode Table β contains the actual file metadata on disk.
This architecture is a big reason why Unix-like systems are so flexible, consistent, and developer-friendly.
Top comments (0)