fflush · shipping · also fflush(), fflush(3)

fflush

fflush is a C standard-I/O operation that passes pending output from a stream's user-space buffer to its underlying write function.

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. [1]

For 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. [1] [2]

Relations

related
fwrite, fclose, fsync, File descriptor

Limitations

  • Flushing a user-space output buffer is not a durability acknowledgement.

Citations

  1. Linux man-pages 6.19: fflush(3) (accessed 2026-10-21)
  2. Linux man-pages 6.19: fsync(2) (accessed 2026-10-21)

Further reading

  1. Hesela: The user-space buffer comes before fsync (accessed 2026-10-21)

JSON: /data/terms/fflush.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. fflush. Hesela. 2026-10-21. https://hesela.dev/terms/fflush/