Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

flockfile(3S)

fopen(3S)

ferror(3S)

NAME

ferror(), ferror_unlocked(), feof(), feof_unlocked(), clearerr(), clearerr_unlocked() − stream status inquiries

SYNOPSIS

#include <stdio.h>

int ferror(FILE *stream);

int ferror_unlocked(FILE *stream);

int feof(FILE *stream);

int feof_unlocked(FILE *stream);

void clearerr(FILE *stream);

void clearerr_unlocked(FILE *stream);

DESCRIPTION

ferror() Returns non-zero when an I/O error has previously occurred reading from or writing to the named stream, otherwise zero. Unless cleared by clearerr(), or unless the specific stdio routine so indicates, the error indication lasts until the stream is closed. 

feof() Returns non-zero when EOF has previously been detected reading the named input stream, otherwise zero.

clearerr() Resets the error indicator and EOF indicator on the named stream to zero. 

ferror_unlocked(), feof_unlocked(), and clearerr_unlocked() are identical to ferror(), feof(), and clearerr() respectively except they do not perform any internal locking of the stream for multi-thread applications.  The _unlocked routines can be used by multi-thread applications which have already used flockfile() to acquire a mutual exclusion lock for the stream (see flockfile(3S)).

WARNINGS

All these routines are implemented both as library functions and as macros.  The macro versions, which are used by default, are defined in <stdio.h>.  To obtain the library function, either use a #undef to remove the macro definition or, if compiling in ANSI-C mode, enclose the function name in parentheses or use the function address.  The following example illustrates each of these methods :

#include <stdio.h>
#undef ferror
    ...
main()
{
int (*find_error()) ();
         ...
return_val=ferror(fd);
         ...
return_val=(feof)(fd1);
         ...
find_error = feof;
};

Reentrant Interfaces

If _REENTRANT is defined before including <stdio.h>, the locked versions of the library functions for ferror(), feof(), and clearerr() are used by default. For multi-thread applications, if _STDIO_UNLOCK_CHAR_IO is also defined before including <stdio.h>, the unlocked macro versions will be used by default for ferror(), feof(), and clearerr(). 

SEE ALSO

open(2), flockfile(3S), fopen(3S). 

STANDARDS CONFORMANCE

ferror(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

clearerr(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

feof(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Hewlett-Packard Company  —  HP-UX Release 10.20:  July 1996

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026