File Descriptor
Subject: Computer and Technology noun /ˈfaɪl dɪˈskrɪp.tər/ 1 definition
- operating-systems
- systems-programming
- input-output
- file-systems
-
Definition (noun)
Entry #135 · UpdatedA File Descriptor (FD) is a non-negative integer handle assigned by a POSIX-compliant or Unix-like operating system kernel to identify an open input/output (I/O) resource within a running process. Instead of exposing internal kernel structures directly to user space, the kernel indexes each FD in a per-process descriptor table that maps to an open file description tracking the access mode, current byte offset, and underlying kernel object. By presenting regular files, pipes, sockets, and devices through one uniform integer interface, FDs enable programs to invoke generic system calls such as
read,write, andclosewhile keeping permissions, process isolation, and open-handle limits under strict kernel control.Common Types
Standard Streams: Pre-opened descriptors automatically inherited by new processes—
0for standard input (stdin),1for standard output (stdout), and2for standard error (stderr)—to support terminal I/O, shell redirection, and command pipelines.Filesystem Descriptors: Handles returned by
open()oropenat()for regular files and directories, supporting metadata operations and sequential or random-access I/O through a kernel-tracked byte offset.Pipe and Socket Descriptors: Descriptors created for unidirectional pipes, named FIFOs, or network sockets (
socket()), enabling byte-stream or datagram communication between processes or hosts without seekable file offsets.Event and Device Descriptors: Kernel objects exposed as integers—such as Linux
epoll,timerfd, andeventfdinstances or character device nodes under/dev—allowing event loops to multiplex timers, signals, and hardware I/O uniformly.
Example
When a web server accepts an incoming client connection on Linux, the
accept()system call allocates the lowest unused file descriptor—such as7—in the process descriptor table and links it to the new TCP socket. The server monitors FD7viaepoll_wait(), exchanges HTTP payloads usingread()andwrite(), and callsclose(7)when finished so the kernel can reclaim that descriptor slot for future connections.