home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
OSKBox.lzh
/
MAILBOX
/
CC
/
logmon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-08
|
666b
|
35 lines
#include "mailbox.h"
main (argc, argv)
char *argv[];
{
int f;
long oldlen, len, linelen;
char line[200];
int sec = 15;
if (argc > 1) {
sec = atoi (argv[1]);
if (sec <= 0)
sec = 15;
}
chdir (HOME);
if ((f = open ("logfile", 1)) < 0)
exit (0, printf ("error %d opening logfile.\n"));
oldlen = _gs_size (f);
close (f);
while (1) {
sleep (sec);
if ((f = open ("logfile", 1)) < 0)
exit (0, printf ("error %d opening logfile.\n"));
len = _gs_size (f);
if (len != oldlen) {
lseek (f, (long) oldlen, 0);
while ((linelen = readln (f, line, sizeof (line))) > 0)
writeln (1, line, linelen);
oldlen = len;
}
close (f);
}
}