{
  "slug": "end-of-file",
  "term": "End of file",
  "aliases": [
    "EOF"
  ],
  "definition": "End of file (EOF) is the boundary at a regular file's current logical length, or an end-of-input condition reported by an input interface.",
  "note": "For a regular file, a successful read with a positive requested count returns zero when its starting offset is at or beyond the current end. A zero-count request can also return zero without testing that boundary. A positive short read is not itself a zero-byte EOF result. [read]\n\nUnwritten gaps before EOF yield zero-valued bytes, not an absence of bytes. Seeking beyond EOF does not extend the file. A later write can grow it; consequently, an earlier EOF observation is not proof that no future read can obtain data. [posix-read] [lseek]\n\nFor an empty pipe or FIFO, EOF requires that no write end remains open. A positive-count read of an empty buffer with a writer still present instead leads to waiting or, in nonblocking mode, EAGAIN. This is a communication-lifetime condition, not a regular-file size measurement. [pipe]\n\nThe C feof() function tests a stream's recorded indicator, not current file length. fgetc() returns EOF while that indicator remains set, even after growth. clearerr() clears EOF and error indicators without moving the stream position; a successful fseek() also clears EOF. Clearing the indicator does not guarantee another byte. fgetc() can also return EOF for a read error: distinguish it with ferror(). [feof] [fgetc] [clearerr] [fseek]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "EOF does not verify a complete backup, unchanged contents or durable storage.",
    "The interpretation of a zero return depends on the interface, object type and requested count."
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "related": [
    "file-size",
    "file-offset",
    "regular-file",
    "sparse-file",
    "short-read"
  ],
  "citations": [
    {
      "id": "read",
      "title": "Linux man-pages: read(2), zero count and return values",
      "url": "https://man7.org/linux/man-pages/man2/read.2.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "posix-read",
      "title": "POSIX.1-2017: read(), unwritten ranges and end of input",
      "url": "https://man7.org/linux/man-pages/man3/read.3p.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "lseek",
      "title": "Linux man-pages: lseek(2), seeking past EOF",
      "url": "https://man7.org/linux/man-pages/man2/lseek.2.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "pipe",
      "title": "Linux man-pages: pipe(7), empty buffers and writer lifetime",
      "url": "https://man7.org/linux/man-pages/man7/pipe.7.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "feof",
      "title": "POSIX.1-2017: feof(), stream end-of-file indicator",
      "url": "https://man7.org/linux/man-pages/man3/feof.3p.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "fgetc",
      "title": "POSIX.1-2017: fgetc(), stream state and return values",
      "url": "https://man7.org/linux/man-pages/man3/fgetc.3p.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "clearerr",
      "title": "POSIX.1-2017: clearerr(), stream state and return values",
      "url": "https://man7.org/linux/man-pages/man3/clearerr.3p.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "fseek",
      "title": "POSIX.1-2017: fseek(), stream state and return values",
      "url": "https://man7.org/linux/man-pages/man3/fseek.3p.html",
      "accessed": "2026-11-15"
    },
    {
      "id": "hesela-capacity",
      "title": "Hesela: File length, EOF and zero bytes",
      "url": "https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/#file-size-eof",
      "accessed": "2026-11-15"
    }
  ],
  "provenance": [
    "Primary-documentation synthesis. POSIX references are the cited 2017 reproductions, not the 2024 edition.",
    "A six-case Linux/glibc interface demonstration accompanies the related analysis; it does not test crash durability or other C libraries."
  ]
}
