ferror · shipping · also ferror(), ferror(3)

ferror

ferror is a C standard-I/O operation that tests whether a stream's error indicator is set.

Related Observatory article: ferror on hesela.com

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

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

Hesela'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. [3]

Relations

related
clearerr, fwrite, fflush, fclose, fsync

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.

Citations

  1. Linux man-pages: ferror(3), clearerr(3) and errno (accessed 2026-10-21)
  2. glibc 2.39: ferror implementation (accessed 2026-10-21)
  3. Hesela: cross-libc fwrite observations and stream error history (accessed 2026-10-21)

JSON: /data/terms/ferror.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

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