What flag?

You need an atomic set-and-check process, and without access to latches/semaphores the "open a file in exclusive read mode" it about as close as you are going to get.