File Descriptor

What Does File Descriptor Mean?

For most operating systems, a file descriptor (FD) is a small non-negative integer that helps in identifying an open file within a process while using input/output resources like network sockets or pipes. In a way, it can be considered as an index table of open files. When there are read, write or closing file operations, one of the input parameters considered is the file descriptor. File descriptors form an important component of POSIX application programming interface and provide a primitive, low-level interface to input or output operations.


Techopedia Explains File Descriptor

A kernel creates a file descriptor whenever it encounters an open call. In many ways, the gateway into the kernel’s abstractions of underlying hardware can be considered as file descriptors. In the Unix operating system, the standard input is represented by file descriptor 0, the standard output is represented by file descriptor 1 and standard error file is represented by file descriptor 2. In other words, corresponding to the three standard streams, each UNIX process would have three standard file descriptors. Both streams and file descriptors can represent a device connection, however for controlling specific devices, file descriptors need to be used. In most operating systems such as UNIX, file descriptors are represented as objects of type “int.” The file descriptor is used by the kernel as an index in the file description table in order to determine which process originally opened a specific file and then allow performing the requested operations on the opened device or file.

From an application programming perspective, file descriptors need to be used if there are any input or output operations in special modes, including non-blocking inputs. Unlike streams which provide high functions for controlling, a file descriptor interface provides only simple functions for the transfer of character blocks. Low-level operations can be performed directly on the file descriptor.


Related Terms

Latest Computer Science Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…