Lines Matching defs:lock
46 * Use an advisory lock to ensure that only one daemon process is
47 * active in the system at any point in time. If the lock is held
49 * the lock to the caller immediately. The lock is cleared if the
50 * holding daemon process exits for any reason even if the lock
55 * check if another process is holding lock on the lock file.
65 struct flock lock;
73 lock.l_type = F_WRLCK;
74 lock.l_whence = SEEK_SET;
75 lock.l_start = (off_t)0;
76 lock.l_len = (off_t)0;
78 err = fcntl(fd, F_GETLK, &lock);
84 return ((lock.l_type == F_UNLCK) ? 0 : 1);
97 * We want to create a lock file named like this:
98 * $_PATH_SYSVOL/nfs-status.lock
122 (void) snprintf(lock_file, MAXPATHLEN, _PATH_SYSVOL "/%s.lock", p);
133 * lock the file, write caller's pid to the lock file
134 * return: 0 if caller can establish lock, else,
135 * pid of the current lock holder, else,
144 struct flock lock;
152 lock.l_type = F_WRLCK;
153 lock.l_whence = SEEK_SET;
154 lock.l_start = (off_t)0;
155 lock.l_len = (off_t)0;
157 if (fcntl(fd, F_SETLK, &lock) == -1) {
158 if (fcntl(fd, F_GETLK, &lock) == -1) {
163 return (lock.l_pid);