fpurge(3)

fpurge3

Purge a stream

Usage

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

int fpurge(FILE *stream);

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

void __fpurge(FILE *stream);

Library

Standard C library (libc, -lc)

Overview

The function fpurge() clears the buffers of the given stream. For output streams this discards any unwritten output. For input streams this discards any input read from the underlying object but not yet obtained via getc(3); this includes any text pushed back via ungetc(3). See also fflush(3).

The function __fpurge() does precisely the same, but without returning a value.

Return value

Upon successful completion fpurge() returns 0. On error, it returns -1 and sets errno to indicate the error.

Errors

EBADF

stream is not an open stream.

Attributes

For an explanation of the terms used in this section, see attributes(7).

InterfaceAttributeValue
__fpurge()Thread safetyMT-Safe race:stream

Notes

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

Releases

17 releases since Debian 1.1 (Buzz); the text changed 14 times.

  1. 1.1–1.2
  2. 1.3
  3. 2.0–2.1
  4. 3.1
  5. 4.0
  6. 5.0
  7. 6.0
  8. 7
  9. 8
  10. 9
  11. 10
  12. 11
  13. 12
  14. 13
  15. Arch

Standards

None.

History

fpurge()

4.4BSD. Not available under Linux.

__fpurge()

Solaris, glibc 2.1.95.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.