Lines Matching refs:lock
27 * Set an exclusive advisory lock on the open file descriptor [fd].
28 * Return 0 on success, 1 if a conflicting lock is held by another process,
34 struct flock lock;
40 lock.l_type = F_WRLCK;
41 lock.l_whence = SEEK_SET;
42 lock.l_start = 0;
43 lock.l_len = 0;
45 if (fcntl(fd, F_SETLK, &lock) < 0) {
55 * Release an advisory lock held on the open file descriptor [fd].
61 struct flock lock;
67 lock.l_type = F_UNLCK;
68 lock.l_whence = SEEK_SET;
69 lock.l_start = 0;
70 lock.l_len = 0;
72 if (fcntl(fd, F_SETLK, &lock) < 0)
79 * Test whether an exclusive advisory lock could be obtained for the open
82 * holding a conflicting lock, or -1 on error (with errno set).
87 struct flock lock;
93 lock.l_type = F_WRLCK;
94 lock.l_whence = SEEK_SET;
95 lock.l_start = 0;
96 lock.l_len = 0;
98 if (fcntl(fd, F_GETLK, &lock) < 0)
101 if (lock.l_type == F_UNLCK)
104 return (lock.l_pid);