Thanks, we made a good progress, but still I think somehow we are on the wrong track, mixing up three different things: file locking, file permissions and existence of a file.
My original goal was to hand over "tasks" from program A to program B in a file. For that file locking (flock) would be the ideal solution (no need even for a separate lock file, the task file is locked in itself). While A is updating the tasklist it locks the file and similarly while B cleans the tasks it can also lock. The problem is that the flock mechanism under Linux is unreliable. It is called "advisory", i.e. processes either take it into account or not:
https://www.baeldung.com/linux/file-locking. Often it can be made mandatory when the file system is mounted, but in certain cases it does not work at all (NFS). So this is a no solution.
You can test it. If in your program while waiting for ENTER you open the lock file in e.g. Gedit (for non-Linux users it is the "notepad" of gnome under Linux), it does not respect the advisory rights and simply opens it and you can write in it, save it, etc. Once you press ENTER the file is deleted normally, because Linux does not care that someone has also touched it in the meantime.
You are right though that flock is released once the process terminates, so even a program respecting flock can acquire it again (no permanent locking out).
The second thing is the file permissions. Yesterday with the wrong FileCreate this is why tmp work differently than the home directory. Apparently Linux set different permissions in the two cases. Now, as it is explicitly specified there is no difference.
If the lock file is created without read and write permission even for the owner (&xxx AND &600 <> &600) it is created as a non accessible file. In Nautilus (File explorer of gnome/linux) the file is shown with a little lock icon. Now, if the process crashes without deleting the file, it remains there with restricted access. No other process can "acquire" it. Gedit cannot open it either.
Still any process under the same user can delete the file and thus sort-of release the lock.
It can be used as a "locking" mechanism even if access rights are not specified.
Lock := FileCreate(LockFilePath, &577);
works just as with access right (I chose &577 just to show that it is enough if 2 or 4 is missing from the owner's permissions. Here the problem might again be (I did not test), how it behaves on different file systems or over network access.
This is why I came up with the original problem, create a file if it does not exist and fail if the file exists regardless with what permission, what locking. For this problem I still do not have a solution.
Is my assessment correct, or do I miss something?