/* $Id: follow.c,v 1.1 2007-07-24 07:29:41 gophi Exp $ */

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#define die(...) do { \
	fprintf(stderr, "follow: "); \
	fprintf(stderr, __VA_ARGS__); \
	fprintf(stderr, "\n"); \
	exit(EXIT_FAILURE); \
} while (0)

int main(int ac, char * const av[])
{
	FILE *fp;

	if (ac < 2)
		die("syntax error");

	fp = fopen(av[1], "r");
	if (!fp)
		die("fopen(): %s", strerror(errno));

	for (;;) {
		int ch = fgetc(fp);

		if (ch == EOF) {
			usleep(50000);
			continue;
		}

		fputc(ch, stdout);
	}

	/* NOTREACHED */

	fclose(fp);

	return 0;
}
