flock is associated with open-file-description, and open(2) creates new open-file-description. So invoking flock(1) in two separate shells will open the lock file separately and result in two open-file-descriptions. How could flock(1) know the lock status associated with each open-file-description? I am confused... Also, does flock(1) treat path name and file descriptor differently?
The flock I am talking about is the one under Linux.
In my understanding, the struct representing flock is system-wide unique. One or more open-file-descriptions may reference to one flock struct (like the relationship between open-file-description and i-node). Is my 'guess' correct?