EACCES is already ignored when creating lock files. In this case we
assume that the file to be locked is part of the system-wide
installation. On NixOS however, the file system containing system
packages is mounted read-only, and open(2) returns EROFS.
@wizardbc found that this is needed while working on lean.js.
I think it's because of the use of O_CREAT in open system call.
Related issue: leanprover/lean.js#10
Remark: the lock are not being erased on Windows.
I tried different solutions based on MoveFileEx and DeleteFile.
None of them worked. The one based on MoveFileEx
MoveFileEx(m_fname.c_str(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
seems to delete the file after REBOOT.
But, this is not very useful.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>