|
|
1.1 ! root 1: /* ! 2: * remove uucp lock files if idle ! 3: * assume it really is a lockfile; ! 4: * assume ascii locks for now (it's easy to fix) ! 5: */ ! 6: ! 7: #include <stdio.h> ! 8: ! 9: #define HUGE 30000 ! 10: ! 11: main(argc, argv) ! 12: int argc; ! 13: char **argv; ! 14: { ! 15: FILE *fp; ! 16: int pid; ! 17: ! 18: if (argc <= 1) { ! 19: fprintf(stderr, "usage: %s lockfile ...\n", argv[0]); ! 20: exit(1); ! 21: } ! 22: while (--argc > 0) { ! 23: if ((fp = fopen(*++argv, "r")) == NULL) { ! 24: fprintf(stderr, "%s: cannot open\n", *argv); ! 25: continue; ! 26: } ! 27: if (fscanf(fp, "%d", &pid) != 1 || pid <= 0) { ! 28: fprintf(stderr, "%s: bad format\n", *argv); ! 29: continue; ! 30: } ! 31: if (kill(pid, 0) >= 0 ! 32: || errno != ESRCH) ! 33: continue; ! 34: unlink(*argv); ! 35: } ! 36: exit(0); ! 37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.