in reply to Trying to understand flock

It would be a very nice thing if Unix did implement mandatory locking, but it doesn’t.   You can use other mechanisms to safeguard cooperating processes, but you generally can’t extend the same courtesy to “outside” apps.   Very unfortunate, but true.