int flock(int fd, int operation);
Apply or remove an advisory lock on an open file. The file is specified by fd. Valid operations are given below:
Shared lock. More than one process may hold a shared lock for a given file at a given time.
Exclusive lock. Only one process may hold an exclusive lock for a given file at a given time.
Don't block when locking. May be specified (by or'ing) along with one of the other operations.
A single file may not simultaneously have both shared and exclusive locks.