fflush(3)
โจ fflush(3) โ Library Functions Manual โจ
okay bestie, welcome to the fflush(3) page, it's giving "library functions manual" energy and honestly? iconic. ๐
๐ธ NAME ๐ธ
fflush โ flush a stream ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โ she's built in, no extra shopping required ๐ซถ
โจ SYNOPSIS โจ
#include <stdio.h>
int fflush(FILE *_Nullable stream);
that's it. that's the whole vibe check. one function, one argument, go off queen ๐
๐ DESCRIPTION ๐
okay so for output streams, fflush() forces a write of all user-space buffered data for the given output or update stream, and it does it via the stream's underlying write function. like, everything hanging out in the buffer? out the door. flushing it. periodt. ๐ฝโจ
for input streams that are associated with seekable files (think disk files, but NOT pipes or terminals, she's picky), fflush() discards any buffered data that has been fetched from the underlying file but has not been consumed by the application. yeah, it just throws it away bestie, that data said bye ๐
the open status of the stream is unaffected. it's still open, still valid, still that girl. no cap.
if the stream argument is NULL, fflush() flushes all open output streams. all of them. every single one. group-chat announcement energy ๐ข
for a nonlocking counterpart, see unlocked_stdio(3) โ iykyk ๐
โญ RETURN VALUE โญ
upon successful completion, 0 is returned. slay. ๐
otherwise, EOF is returned and errno is set to indicate the error. not slay. ๐ญ
๐ ERRORS ๐
EBADFโstreamis not an open stream, or is not open for writing. like girl, that's not a stream, or it's not even open for writing, what are you doing ๐
also, fflush() may fail and set errno for any of the errors specified for write(2) โ so go check that page too, she's got receipts.
๐ ATTRIBUTES ๐
for an explanation of the terms used in this section, see attributes(7).
- Interface:
fflush() - Attribute: Thread safety
- Value:
MT-Safe
(she's MT-Safe, she can hang with the whole group at once, no drama ๐ )
๐ STANDARDS ๐
C11, POSIX.1-2008.
๐ฆ HISTORY ๐ฆ
C89, POSIX.1-2001, POSIX.1-2008.
and a lil lore drop: POSIX.1-2001 did not specify the behavior for flushing of input streams, but the behavior is specified in POSIX.1-2008. so if you're on the old spec, no promises, bestie ๐ซ
๐ NOTES ๐
note that fflush() flushes only the user-space buffers provided by the C library. it does NOT make your data physically hit the disk. ๐
to ensure the data is physically stored on disk, the kernel buffers must be flushed too โ for example, with sync(2) or fsync(2). two-step process, don't skip leg day fr fr ๐๏ธโ๏ธ
๐ง SEE ALSO ๐ง
fsync(2), sync(2), write(2), fclose(3), fileno(3), fopen(3), fpurge(3), setbuf(3), unlocked_stdio(3)
and that's the whole page, bestie ๐ this was Linux man-pages version 6.20, dated 2025-05-17, and she ate and left no crumbs. go flush something. responsibly. ๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: BSD-4-Clause-UC
- Copyright 1990-1991, The Regents of the University of California
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms