/**
* Function: Read from the /proc/myprocfile in a loop
* when information in the /proc file changes
* Author: Asanga Udugama (adu@comnets.uni-bremen.de)
* License: GPL
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#define MSG_SIZE	1024

int main(int argc, char *argv[])
{
  int fd;
  char buf[MSG_SIZE];
    
  while(1) {
    fd = open("/proc/myprocfile", O_RDONLY);
    if(fd < 0) {
      printf("Cannot open\n");
      exit(1);
    }

    memset(buf, '\0', MSG_SIZE);
    read(fd, buf, MSG_SIZE);
    printf("%s\n", buf);
    
    close(fd);
  }
}
 
