Try something like this:
for (;;) {
while ((ch = getc(fp)) != EOF) {
if (putchar(ch) == EOF)
perror("Output error");
}
if (ferror(fp)) {
printf("Input error: %s", errno);
return;
}
(void)fflush(stdout);
sleep(1); // Or use select
}
You can find a full example by studying the source code for tail. The code above is a modified excerpt from forward.c.
You can use select
to monitor several files for new data (you need to keep them open).