On MacOs, the members of struct flock
have a different order than in Linux.
to make your code portable you should assign the fields by name, and not assume a particular order.
From the MacOS Man page for fcntl:
struct flock {
off_t l_start; /* starting offset */
off_t l_len; /* len = 0 means until end of file */
pid_t l_pid; /* lock owner */
short l_type; /* lock type: read/write, etc. */
short l_whence; /* type of l_start */
};