fpurge(3)

✨ fpurge(3) β€” Library Functions Manual ✨

okay bestie, pull up a chair 🫢 today we're talking about fpurge and its chaotic sibling __fpurge β€” the "purge a stream" girlies of the manual pages. welcome to the Library Functions Manual πŸ’…


🌸 NAME 🌸

fpurge, __fpurge β€” purge a stream 🧹✨


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so there's the version that nobody supports and the version that's actually supported, and the manpage wants you to know the difference upfront, so:

the unsupported one πŸ™ˆ:

/* unsupported */
#include <stdio.h>

int fpurge(FILE *stream);

the supported one πŸ‘‘:

/* supported */
#include <stdio.h>
#include <stdio_ext.h>

void  __fpurge(FILE *stream);

periodt. πŸ’…


πŸ’– DESCRIPTION πŸ’–

so, the function fpurge() does one thing and does it well: it clears the buffers of the given stream. that's the vibe. 🧚

what "clearing" actually means depends on which way the stream is flowing:

  • for output streams, it discards any unwritten output β€” like, bye, we're not sending that πŸ’€
  • for input streams, it discards any input that's already been read off the underlying object but hasn't been handed to you yet via getc(3). and yes bestie, this includes any text you pushed back with ungetc(3). it's gone, fr fr.

also see fflush(3) if you want the more famous cousin. iykyk.

the function __fpurge() does precisely the same thing, except it doesn't bother returning a value. no thoughts, just purge. ✨


🌈 RETURN VALUE 🌈

  • if it works? fpurge() returns 0 β€” slay πŸŽ‰
  • if it doesn't? it returns -1 and sets errno to tell you what went wrong 😭

πŸ“ ERRORS πŸ“

  • EBADF β€” stream is not an open stream. like girl, that's not even a stream, what are we doing here πŸ™ˆ

πŸ’œ ATTRIBUTES πŸ’œ

for an explanation of the terms used in this section, go peek at attributes(7) β€” but here's the tea:

  • __fpurge() β€” Thread safety: MT-Safe race:stream ⭐

πŸŽ€ STANDARDS πŸŽ€

None. 😢 nothing. zero. the standards girlies said "not us". πŸ’€


πŸ”₯ HISTORY πŸ”₯

  • fpurge() β€” 4.4BSD. Not available under Linux. ok that's important, do not come for me if you try it on Linux πŸ‘‘
  • __fpurge() β€” Solaris, glibc 2.1.95. she's been around a minute πŸ’…

⭐ NOTES ⭐

Usually it is a mistake to want to discard input buffers. 🫢

like, lowkey listen to the manpage on this one bestie, she knows what she's talking about.


πŸ‘‘ SEE ALSO πŸ‘‘

fflush(3), setbuf(3), stdio_ext(3)


and that's the whole page, babe β€” brought to you by Linux man-pages 6.20, dated 2026-02-08, filed under fpurge(3) πŸ’–βœ¨ mwah, go purge 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: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms