{
  "slug": "fflush",
  "term": "fflush",
  "aliases": [
    "fflush()",
    "fflush(3)"
  ],
  "definition": "fflush is a C standard-I/O operation that passes pending output from a stream's user-space buffer to its underlying write function.",
  "note": "For an output stream, zero reports a successful flush; EOF reports failure with errno set. Capture the failure before cleanup. The stream remains open. Input-stream flushing has a separate contract. [linux-fflush]\n\nFor a descriptor-backed output stream, check the intended writes and fflush before fsync(fileno(stream)); fsync cannot submit bytes still held in the library buffer. Serialize concurrent output around that boundary. Neither operation alone supplies multi-file atomicity or directory-entry persistence. [linux-fflush] [linux-fsync]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "Flushing a user-space output buffer is not a durability acknowledgement."
  ],
  "related": [
    "fwrite",
    "fclose",
    "fsync",
    "file-descriptor"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "linux-fflush",
      "title": "Linux man-pages 6.19: fflush(3)",
      "url": "https://man7.org/linux/man-pages/man3/fflush.3.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "linux-fsync",
      "title": "Linux man-pages 6.19: fsync(2)",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "hesela-stdio",
      "title": "Hesela: The user-space buffer comes before fsync",
      "url": "https://hesela.com/analyses/fsync-failure-retry-durability/#stdio-buffer",
      "accessed": "2026-10-21"
    }
  ],
  "updated": "2026-10-21"
}
