Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!lsuc!dave From: dave@lsuc.UUCP Newsgroups: comp.bugs.4bsd,comp.bugs.misc Subject: fix to tra(1) to account for file getting smaller Message-ID: <1797@lsuc.UUCP> Date: Sun, 17-May-87 02:15:32 EDT Article-I.D.: lsuc.1797 Posted: Sun May 17 02:15:32 1987 Date-Received: Sun, 17-May-87 05:35:17 EDT Organization: Law Society of Upper Canada, Toronto Lines: 35 (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