Understanding File Descriptors
Explore how file descriptors function as integer handles that connect a process to open files and other resources. Understand the role of the first three descriptors, how the kernel manages them, and why treating files and devices uniformly simplifies programming at the system level.
In the previous lesson, we learned that system I/O functions such as open(), read(), and write() operate at a lower level than standard I/O. These functions do not use FILE * objects. Instead, they operate using integers known as file descriptors.
In this lesson, we explore what file descriptors are, why every process starts with three of them, and how the operating system uses them to unify files, devices, and communication channels.
What is a file descriptor?
A file descriptor is a non-negative integer that identifies an open file (or resource) within a process. When a process opens a file using open(), the operating system locates the ...