Logo Search packages:      
Sourcecode: leafnode version File versions

int handover_lock ( pid_t  pid  ) 

Tries to hand over lock to the process with the given pid.

Returns:
0 for success, nonzero for failure -- check errno for details in case of error.

Definition at line 327 of file lockfile.c.

                             {
  int fd = open(lockfile, O_RDWR|O_TRUNC, (mode_t)0600);
  char *buf = (char *)critmalloc(strlen(fqdn) + sizeof(unsigned long) * 4 + 4,
                         "handover_lock");
  if (fd < 0) { free(buf); return fd; }
  sprintf(buf, "%lu\n%s\n", (unsigned long)pid, fqdn);
  if (-1 == writes(fd, buf)) goto close_bail;
  if (-1 == fsync(fd)) goto close_bail;
  if (-1 == close(fd)) goto close_bail;
  free(buf);
  return 0;

 close_bail:
  (void)close(fd); 
  free(buf);
  return -1;
}


Generated by  Doxygen 1.6.0   Back to index