@whitequark I'm possibly a bit confused. A flock() lock is automatically released when the last copy of its file descriptor (its 'open file', the shared-over-dup/fork underlying fds) is closed. If you flock() and close the lock is gone.
If you do two open()s of the same file in the same process, flock() one (holding the fd open), and then try to flock() the other, AFAIK the second flock() will block, just as it would in a separate process. But I'd test it to be sure.