#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/signal.h>


#define  fil  "/etc/.comm_cshrc"
int i = 0,j = 0,k=0;

main(argc,argv)
  int argc;
  char *argv[];
{
	extern unsigned alarm();
	extern void wakeup();
	struct stat statbuf;
	time_t axtime;


	stat(fil,&statbuf);
	axtime = statbuf.st_atime;
	for(;;)
	{
		if(stat(fil,&statbuf) == -1)
		{
			printf("file %s not there\n",fil);
			exit();
		}
		if (axtime != statbuf.st_atime)
		{
		/*	printf("file %s accessed\n",fil); */
			i++;
			axtime = statbuf.st_atime;
		}
		signal(SIGALRM,wakeup);
		alarm(1);
		pause();

	}
}

void wakeup()
{
/*	printf("\033[s\033[1;68H%i Axcess's\033[u",i);
*/
	if( i != j){
		j = k;
		k = i;
		if(i != j)
		printf("**LOGIN**");
		printf("\07");
		fflush(stdout);
	}
}

