File:  [Research Unix] / researchv10no / cmd / uucp / rmlock.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/*
 * remove uucp lock files if idle
 * assume it really is a lockfile;
 * assume ascii locks for now (it's easy to fix)
 */

#include <stdio.h>

#define	HUGE	30000

main(argc, argv)
int argc;
char **argv;
{
	FILE *fp;
	int pid;

	if (argc <= 1) {
		fprintf(stderr, "usage: %s lockfile ...\n", argv[0]);
		exit(1);
	}
	while (--argc > 0) {
		if ((fp = fopen(*++argv, "r")) == NULL) {
			fprintf(stderr, "%s: cannot open\n", *argv);
			continue;
		}
		if (fscanf(fp, "%d", &pid) != 1 || pid <= 0) {
			fprintf(stderr, "%s: bad format\n", *argv);
			continue;
		}
		if (kill(pid, 0) >= 0
		||  errno != ESRCH)
			continue;
		unlink(*argv);
	}
	exit(0);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.