- Additional file descriptor numbers beyond 0, 1, and 2
- The precise definition of a file descriptor
- Why the term “file” descriptor applies to streams like pipes and sockets
Reserved Standard Streams
By convention on Linux and most Unix-like systems, three file descriptors are preallocated for the main I/O streams:| Descriptor Number | Stream | Description |
|---|---|---|
| 0 | stdin | Standard input |
| 1 | stdout | Standard output |
| 2 | stderr | Standard error |

File descriptors are assigned per process. When a program opens a new file, the OS returns the smallest unused descriptor number (starting at 3).
Real-World Analogy: Librarian and Call Numbers
Imagine a library where:- The librarian is your operating system
- Books are files, sockets, or pipes
- Call numbers on the books are file descriptors

Standard Streams Mapped to Descriptors
Applying the library analogy to standard streams:- stdin (0): Asking the librarian which book you want
- stdout (1): Receiving the book from the librarian
- stderr (2): Getting an error message if the book is unavailable
