#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>

int
main(int argc, char **argv) {
	int fd, ret;
	struct timeval tv;
	fd_set fds;
	char buf[100];

	if((fd = __open("irctrl", O_RDWR)) < 0) {
		perror("open()");
		return -1;
	}

	while(-1) {
		tv.tv_sec = 1;
		tv.tv_usec = 0;
		FD_ZERO(&fds);
		FD_SET(fd, &fds);

		ret = __select(fd+1, &fds, 0, 0, &tv);
		if(ret < 0) {
			perror("select()");
			return -1;
		} else if(ret) {
			ret = __read(fd, buf, 100);
			__write(1, buf, ret);
		} else {
			__write(1, ".\n", 2);
		}
	}
}
