NAME

eof - test for end-of-file

SYNOPSIS

short eof(fn)
short fn;

DESCRIPTION

Eof tests the file given by fn to determine if the end-of-file has been reached.  If fn is zero, the current file is used (see initio(io)).  Eof returns -1 if end-of-file has been reached and zero otherwise.  If the file is a tty, zero is always returned. 

In support of pipes, this function closes the output side of a pipe (if any) using rembiobuf (see initio(io)).  This function then tests for termination of the process.  The output pipe is closed to allow the process to stop reading and processing data; therefore this function may be used only after all data has been output to the process.  The best test for end-of-file from a process is termination of the process.  The test is performed using kill(2); however, since some systems mistake zombies for live processes (usually in shopping malls), eof first creates a process using fork(2) and then waits for its termination using dezomb (see initio(io)), before running kill(2). 

This function resets the current file. 

This function implements the BASIC EOF function. 

SEE ALSO

initio(io)
eof(func)
fork(2), kill(2) in the UNIX Programmerís Manual

DIAGNOSTICS

Error 52 (Bad file number) is generated if fn does not refer to an open file. 

Error 54 (Bad file mode) is generated if the file is open for output only. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber