dave@lsuc.UUCP (05/17/87)
(Dunno whether this bug still exists on other 4BSD versions;
we run Perkin-Elmer's Edition VII Workbench, and the BSD stuff
which comes with it is from 4.1BSD or earlier.)
I wanted to use tra(1) to monitor the end of a file which
might get smaller (specifically, my mail file, which gets
smaller when I read and discard mail), and to pick up from
the new end-of-file point if the file shrinks. (Incidentally,
we don't have BSD's biff(1).)
The hooks were all there; I just had to add one statement:
do {
fstat(0, &stbuf);
if (stbuf.st_size > offset) {
lseek(0, (long) offset, 0);
while ((i = read(0, buf, sizeof buf)) > 0) {
offset =+ i;
write(1, buf, i);
}
}
+ /* David Sherman addition, May 17/87: handle
+ * properly when file gets smaller, e.g. $MAIL
+ */
+ else
+ offset = stbuf.st_size;
sleep(interval);
timeleft =- interval;
} while (timeleft > 0);
David Sherman
The Law Society of Upper Canada
Toronto
--
{ seismo!mnetor cbosgd!utgpu watmath decvax!utcsri ihnp4!utzoo } !lsuc!dave