Understanding File Descriptors
Learn what file descriptors are, and how the operating system uses these integer handles to uniformly manage files, devices, and communication channels.
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 file, creates an internal entry for it, and returns an integer that represents that open file within the process.
Look at an example below: