{
  "slug": "ferror",
  "term": "ferror",
  "aliases": [
    "ferror()",
    "ferror(3)"
  ],
  "definition": "ferror is a C standard-I/O operation that tests whether a stream's error indicator is set.",
  "note": "A nonzero result means the indicator is set; zero means it is clear. This is stream status, not an errno value or a count of failed bytes. With a valid stream, testing the indicator does not change errno. [linux-status]\n\nInspect the result of the I/O operation as well as the stream status. A retained indicator does not identify which earlier operation failed. Preserve failure information before clearerr or stream destruction. The glibc 2.39 implementation tests a flag under the stream's locking rules. [glibc-ferror]\n\nHesela's pinned glibc 2.39 and musl 1.2.5 comparison found a set indicator after a later zero-returning fflush. Its JSON normalizes ferror(stream) != 0 to 0 or 1; those values are not error numbers. This is a controlled API observation, not a storage durability test. [hesela-cross-libc]",
  "status": "shipping",
  "advantages": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-21",
  "limitations": [
    "A clear stream indicator does not establish durable storage completion.",
    "A set indicator does not identify the failing call or the number of affected bytes."
  ],
  "related": [
    "clearerr",
    "fwrite",
    "fflush",
    "fclose",
    "fsync"
  ],
  "citations": [
    {
      "id": "linux-status",
      "title": "Linux man-pages: ferror(3), clearerr(3) and errno",
      "url": "https://man7.org/linux/man-pages/man3/ferror.3.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "glibc-ferror",
      "title": "glibc 2.39: ferror implementation",
      "url": "https://raw.githubusercontent.com/bminor/glibc/glibc-2.39/libio/ferror.c",
      "accessed": "2026-10-21"
    },
    {
      "id": "hesela-cross-libc",
      "title": "Hesela: cross-libc fwrite observations and stream error history",
      "url": "https://hesela.com/analyses/fsync-failure-retry-durability/#fwrite-libc",
      "accessed": "2026-10-21"
    }
  ]
}
