- /* copy report to permanent file */
- sprintf(pfile,"%s/%s/%d",dir,folder,getnext());
- fprintf(stderr,"\t%s\n",pfile);
- if (!(freopen(pfile,"w",stdout)))
- error("unable to create permanent bug file %s.",pfile);
+ if (access(LOCK_FILE, R_OK) || (lfd = open(LOCK_FILE, O_RDONLY, 0)) < 0)
+ error("can't find lock file %s.", LOCK_FILE);
+ if (flock(lfd, LOCK_EX))
+ error("can't get lock.", CHN);
+ sprintf(pfile, "%s/%s/%d", dir, folder, getnext());
+ fprintf(stderr, "\t%s\n", pfile);
+ if (!(freopen(pfile, "w", stdout)))
+ error("can't create %s.", pfile);