Skip to main content
Definition Website Computer and Technology

File Descriptor

Subject: Computer and Technology noun /ˈfaɪl dɪˈskrɪp.tər/ 1 definition

  1. Definition (noun)

    Entry #135 · Updated

    A 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, and close while keeping permissions, process isolation, and open-handle limits under strict kernel control.

    Common Types

    • Standard Streams: Pre-opened descriptors automatically inherited by new processes—0 for standard input (stdin), 1 for standard output (stdout), and 2 for standard error (stderr)—to support terminal I/O, shell redirection, and command pipelines.

    • Filesystem Descriptors: Handles returned by open() or openat() 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, and eventfd instances 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 as 7—in the process descriptor table and links it to the new TCP socket. The server monitors FD 7 via epoll_wait(), exchanges HTTP payloads using read() and write(), and calls close(7) when finished so the kernel can reclaim that descriptor slot for future connections.