carta
fileno_unlocked(3)

fileno_unlocked3

Check and reset stream status

Part of clearerr(3).

Usage

void

void

int

int

int

int

int

int

Library

Standard C Library (libc, -lc)

Overview

The function clearerr() clears the end-of-file and error indicators for the stream pointed to by stream.

The function feof() tests the end-of-file indicator for the stream pointed to by stream, returning non-zero if it is set. The end-of-file indicator may be cleared by explicitly calling clearerr(), or as a side-effect of other operations, e.g. fseek().

The function ferror() tests the error indicator for the stream pointed to by stream, returning non-zero if it is set.

The function fileno() examines the argument stream and returns its integer descriptor.

The clearerr_unlocked(), feof_unlocked(), ferror_unlocked(), and fileno_unlocked() functions are equivalent to clearerr(), feof(), ferror(), and fileno() respectively, except that the caller is responsible for locking the stream with flockfile(3) before calling them. These functions may be used to avoid the overhead of locking the stream and to prevent races when multiple threads are operating on the same stream.

Errors

These functions, except fileno(), should not fail and do not set the external variable errno.

On error, fileno() returns -1 and sets errno to one of the following values:

[EBADF]

The stream is not associated with a file.

[EBADF]

The file descriptor underlying stream is not a valid file descriptor.

Note that detection of this condition is not reliable, the error might be not reported.

History

  • FreeBSD 16.0-CURRENT (2026-10-27) to FreeBSD 15.0-RELEASE: the text shown here
  • FreeBSD 14.5-RELEASE to FreeBSD 14.3-RELEASE
  • FreeBSD 14.2-RELEASE to FreeBSD 13.3-RELEASE
  • FreeBSD 13.2-RELEASE
  • FreeBSD 13.1-RELEASE to FreeBSD 13.0-RELEASE
  • FreeBSD 12.4-RELEASE
  • FreeBSD 12.3-RELEASE
  • FreeBSD 12.2-RELEASE
  • FreeBSD 12.1-RELEASE
  • FreeBSD 12.0-RELEASE
  • FreeBSD 11.4-RELEASE
  • FreeBSD 11.3-RELEASE
  • FreeBSD 11.2-RELEASE
  • FreeBSD 11.1-RELEASE
  • FreeBSD 11.0-RELEASE
  • FreeBSD 10.4-RELEASE
  • FreeBSD 10.3-RELEASE
  • FreeBSD 10.2-RELEASE
  • FreeBSD 10.1-RELEASE
  • FreeBSD 10.0-RELEASE
  • FreeBSD 9.3-RELEASE
  • FreeBSD 9.2-RELEASE
  • FreeBSD 9.1-RELEASE
  • FreeBSD 9.0-RELEASE
  • FreeBSD 8.4-RELEASE
  • FreeBSD 8.3-RELEASE
  • FreeBSD 8.2-RELEASE
  • FreeBSD 8.1-RELEASE
  • FreeBSD 8.0-RELEASE
  • FreeBSD 7.4-RELEASE
  • FreeBSD 7.3-RELEASE
  • FreeBSD 7.2-RELEASE
  • FreeBSD 7.1-RELEASE
  • FreeBSD 7.0-RELEASE
  • FreeBSD 6.4-RELEASE
  • FreeBSD 6.3-RELEASE to FreeBSD 5.1-RELEASE

Standards

The functions clearerr(), feof(), and ferror() conform to ISO/IEC 9899:1990 (“ISO C90”).

History

The functions clearerr(), feof(), ferror(), and fileno() first appeared in Version 7 AT&T UNIX.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.