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.