+ {
+ if (errno != EEXIST)
+ {
+ yaz_log(LOG_FATAL|LOG_ERRNO, "lock file %s", pidfile);
+ exit(1);
+ }
+ fd = open(pidfile, O_RDWR, 0666);
+ if (fd == -1)
+ {
+ yaz_log(LOG_FATAL|LOG_ERRNO, "lock file %s", pidfile);
+ exit(1);
+ }
+ }
+ area.l_type = F_WRLCK;
+ area.l_whence = SEEK_SET;
+ area.l_len = area.l_start = 0L;
+ if (fcntl (fd, F_SETLK, &area) == -1)
+ {
+ yaz_log(LOG_ERRNO|LOG_FATAL, "Zebra server already running");
+ exit(1);
+ }