jchvr@ihlpg.UUCP (VanRietschote) (01/07/86)
--- mklock will create a lock file which can be tested against to disallow the concurrent access to a shared resource. It is simple but does the trick. For more info see next news item with manual page. Feel free to use or abuse this program at your own risk. --- cut here --- /* mklock.c to create .lock file -*-update-version-*- * HFVR VERSION=Thu Apr 11 10:39:33 1985 * Usage: mklock file */ #include <stdio.h> main(argc,argv) int argc; char *argv[]; { int f; if (argc != 2) { fprintf(stderr,"\007%s: exactly one argument expected\n",argv[0]); exit(1); }/*fi*/ if ((strcmp(argv[1],"-?") == 0)) { fprintf(stderr,"%s creates lock file. Usage: %s file.\n",argv[0],argv[0]); exit(1); }/*fi*/ if ((f = creat(argv[1],0)) < 0) { fprintf(stderr,"\007%s: ",argv[0]); perror(""); exit(1); } else { close(f); exit(0); }/*fi*/ }