Eli Zaretskii writes: >> From: Matt Armstrong >> Cc: 46397@debbugs.gnu.org, eggert@cs.ucla.edu, craven@gmx.net >> Date: Wed, 24 Feb 2021 09:37:49 -0800 >> >> I still like my original idea of calling display-warning for all unlock >> errors, essentially turning "unlock" into a best effort function at the >> API level. I think display-warning is intrusive enough that users are >> unlikely to simply not notice the problem, and there are worse things >> than leaving lock files around. > > OK, you've convinced me: let's try the warning approach. Can you > present a patch for that, please? Thanks Eli, will do. I have made progress with that idea, but I'd rather get the test in first. See patch attached below. > As for the tests you posted: too many of them rely on Posix file > modes, and thus will probably either fail or be unable to provide > meaningful testing on MS-Windows. Can we please augment that by tests > that create unlocking problems by, e.g., running a shell command to > remove or rename or otherwise sabotage the lock file, so that the new > functionality could be meaningfully tested on Windows as well? I have not been able to come up with a way to achieve what you ask for. I have no access to an MS-Windows system to test with, though I have been testing with small FAT and NTFS file systems in a ramdisk under GNU/Linux. It may be possible to take some approach that works on MS-Windows systems, but I'm not in a good position to write that code. Another issue is that the lock file is typicaly a symbolink link, and operating systems typically ignore file modes on symbolic links, so it is hard to put the lock file itself into an "invalid" state -- i.e. where simply attempting to access or delete it generates a file system level error. This is why I resorted to modifying file modes on the containing directory -- attemps to remove or access files in such a directory do reliably generate errors (on POSIX systems). What I've done is make the tests skip themselves when `set-file-mode' on the test's temporary directory appears to not work. When I test this on an ext2 file system the tests complete. When I test this on a FAT and NTFS file system (set up as a ramdisk on GNU/Linux), the tests skip themselves.