int fcntl (int fd, int cmd, struct flock *lock);
struct flock {
...
short l_type; // F_WRLCK, F_RDLCK, F_UNLCK
short l_whence; // SEEK_SET, SEEK_CUR, SEEK_END
off_t l_start; // Starting offset for lock
off_t l_len; // Number of bytes to lock
pid_t l_pid; // Who blocks our lock
...
};
cmd - F_GETLK, F_SETLK, F_SETLKW - advisory or mandatory lock get, set, set with wait
l_type - exclusive, shared, unlock
l_whence - how to interpret starting offset