File Descriptor

Why Trust Techopedia

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.

Advertisements

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.

Advertisements

Related Terms

Margaret Rouse
Technology Specialist
Margaret Rouse
Technology Specialist

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.