4 /* lock a byte range in a open file */
5 int lock_range(int fd, int offset, int len)
10 lock.l_whence = SEEK_SET;
11 lock.l_start = offset;
15 return fcntl(fd,F_SETLK,&lock) == 0;
18 int main(int argc, char *argv[])
25 printf("lockrun <lockfile> <cmd>\n");
32 fd = open(lockf, O_CREAT|O_TRUNC|O_RDWR, 0600);
33 if (fd == -1) exit(1);
35 lock.l_type = F_WRLCK;
36 lock.l_whence = SEEK_SET;
41 if (fcntl(fd,F_SETLKW,&lock) == 0) {