#include #include #include #include #include #include #define FILE "/home/staff/rain/.procmail/new-mail" #define CHECKPERIOD 1 int main(int argc, char *argv[]) { struct stat statbuf; setlinebuf(stdout); for (;;) { if (stat(FILE, &statbuf) == 0) { printf("new %ld\n", statbuf.st_mtime); if (unlink(FILE) < 0) printf("error can't unlink %s: %s\n", FILE, strerror(errno)); } /* check to see whether our parent has gone away */ if (getppid() == 1) return 0; usleep(CHECKPERIOD * 1000000); } return 0; }