Image for file descriptor

file descriptor

A file descriptor is a unique identifier used by an operating system to manage open files and other input/output resources, like sockets or pipes. When a program opens a file, the system assigns a file descriptor—typically a small, non-negative integer—that the program uses to read from, write to, or manipulate the file. Think of it like a ticket number at a service counter; it helps keep track of what resources a program is using, ensuring efficient access and management while preventing conflicts between different parts of the program or other programs.