os/utils.c: Lock file: Refrain from removing "stale" files, remove link-in-place phase, hardening of abnormal situations
Trying to remove lock files determined to be stale is inherently racy (unlink may destroy legitimate lock files re-established in the meantime), causing rare but interesting problems when servers are launched repeatedly. So give up on trying to fix that (which, to be done properly, requires an external coordinator), and just put the burden on an external coordinator (e.g., the user as the last resort). This should not cause problems in practice, since the X server deletes the lock file even in the case of abnormal server termination (also, if an OS crash occur,
/tmp is normally cleaned at boot).
This allows to significantly simplify the lock code, by removing the linking-in-place step altogether (see the commit message in the diff below for how this is possible).
Also, lots of abnormal situations in LockServer(), however unlikely, are not handled properly according to POSIX and arguably need to be fixed and reported properly.
The proposed patch must be applied after that for issue #1131: