tail -f
VLD/VMB
moss at BRL.MIL
Tue Dec 13 13:34:56 AEST 1988
>>I suppose it could use select(2)...
>
>You suppose incorrectly. I know of no UNIX system where "select" will
>permit you to wait for a regular file (as in S_IFREG) file to be
>modified....
Right, he was probably referring to a non-blocking read which won't help
since blocking is really what you want. Anyway, I haven't looked at the
source for 'tail', but I wrote an asynchronous log file monitoring
subroutine to allow the contents of an interactive program's log file to
be displayed in a scrolling window. A subroutine gets called from an
alarm signal handler which loops on fgets() until one fails, then does a
clearerr() (only necessary on some systems like 4.2 BSD) to clear the EOF
condition. Then, the signal handler resets the alarm for N seconds. Of
course you can use sleep() instead of the alarm() call/handler if you
want.
-moss
More information about the Comp.unix.questions
mailing list